Slow Query Logs
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.
Precautions
- 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
- Log in to the DAS console.
- Click in the upper left corner and select a region and project.
- Click in the upper left corner, and under Databases, click Data Admin Service.
- In the navigation pane, choose Intelligent O&M > Instance List.
Alternatively, on the Overview page, click Go to Intelligent O&M.
- 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
- Locate the box containing your target instance and click Details.
- 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.
- 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
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.
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.
- View slow queries over a specified period of time.
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
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot