Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Slow Query Logs

Updated on 2025-01-17 GMT+08:00

This section describes how to analyze slow query logs in a specified period. Slow Query Log displays a chart of SQL statements that are taking too long to execute and allows you to sort slow SQL statements by multiple dimensions, such as by user, host, or SQL template. It helps you quickly identify bottlenecks and improve instance performance.

Usage Notes

  • Enabling Collect Slow Query Logs is a must for slow query logs analysis. After it is enabled, DAS stores the slow query logs for analysis.
  • Slow query logs of free instances are retained for only one hour. For paid instances and free instances that you have subscribed to Intelligent O&M for, their slow query logs are retained for seven days by default and can be retained for up to 30 days. After the retention period expires, slow query logs are deleted.
  • You can enable the slow query logs function for a maximum of 10 free instances. There is no such a limit on paid instances.
  • For free instances, you can only view slow query logs generated in the latest hour.
  • Slow Query Log cannot record all SQL data. As for RDS for MySQL, it has the following constraints:
    • Any slow query log that exceeds 10 KB or whose number of lines exceeds 200 is discarded by default.
  • Version restriction: None

Viewing Slow Query Logs

  1. Log in to the Huawei Cloud console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane, choose Intelligent O&M > Instance List.

    Alternatively, on the Overview page, click Go to Intelligent O&M.

  5. In the upper right corner of the Instance List page, search for instances by engine type, instance name, or instance IP.

    Figure 1 Searching for instances

  6. Locate the target instance and click Details.
  7. Choose SQL > Slow Query Logs.

    If Collect Slow Query Logs is not enabled, enable it as prompted in the Details area.

    Figure 2 Enabling slow query logs collection

    You can also click Log Settings in the upper right corner of the page to enable Collect Slow Query Logs.

  8. On the Slow Query Logs tab page, perform the following operations:

    • View slow queries over a specified period of time.

      Select a time range (last hour, last 3 hours, last 12 hours, or a user-defined time range which must be within three days) to view slow queries in the time range.

      Figure 3 Slow queries over time

      In the chart, you can hover your mouse at any point in time to view slow query logs or CPU usage.

      Above the chart, you can switch to another instance or node to view slow queries by instance or by node.

    • View slow query log details.
      View slow query log details in the lower part of the Slow Query Logs area. The details include the SQL statement, execution start time, database, client, user, execution duration, lock wait duration, and scanned and returned rows.
      Figure 4 Viewing slow query log details

      Click to export slow query log details to a specified OBS bucket. A maximum of 100,000 records can be exported.

      Figure 5 Exporting slow query log details

      After the log details are exported, you can click View Export List to view export records. You can also download the details to your local PC or click Delete to delete the slow query logs.

      Figure 6 Viewing export history
      NOTE:

      Slow query log details of free instances cannot be exported. To use this function, set free instances as paid instances or subscribe to Intelligent O&M.

      Click Concurrency Control in the Operation column to create a concurrency control rule for the current SQL statement. For details, see SQL Statement Concurrency Control.

    • View slow query log statistics.
      Figure 7 Slow query log statistics

      In the template statistics list, click View Sample in the Operation column to view the sample of a SQL statement template.

      Click to export a SQL template to a specified OBS bucket. A maximum of 100,000 records can be exported.

      After the template is exported, you can click View Export List to view export records. You can also download the details to your local PC.

      NOTE:

      Slow query log statistics of free instances cannot be exported. To use this function, set free instances as paid instances or subscribe to Intelligent O&M.

Slow Query Log Storage and Archiving

  • Slow query log storage

    Enabling Collect Slow Query Logs will allow DAS to store slow query logs for analysis.

    Slow query logs of free instances are retained for only one hour. For paid instances and free instances that you have subscribed to Intelligent O&M for, their slow query logs are retained for seven days by default and can be retained for up to 30 days. After the retention period expires, slow query logs are deleted.

    For paid instances and free instances that you have subscribed to Intelligent O&M for, you can click Log Settings in the upper right corner of the SQL page to set slow query log retention days.

    Figure 8 Setting storage duration for slow query logs

    Each paid instance and free instance that you have subscribed to Intelligent O&M for can use 5 GB of storage for slow query logs for free. Any storage used in excess of 5 GB will be billed on a pay-per-use basis.

  • Log archiving
    Slow query logs are automatically archived every 3 minutes. Alternatively, you can click Archive Now and then view the latest statistics.
    Figure 9 Log archiving

    Slow query logs generated in the last 10 days are archived.

    You can click Archive History to view archive records and click Download to download archived slow query logs to your local PC.

    Figure 10 Viewing archive history

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback