Database Autonomy Service (DAS) provides the slow query log analysis feature. You can use this feature to view slow query trends, information about slow query executions, and suggestions on how to optimize slow queries. This topic provides an example to describe how to use the slow query log analysis feature. In this example, ApsaraDB RDS for MySQL instances are used.
- DAS provides the slow query log analysis feature only for the following types of database
- RDS MySQL
- RDS PostgreSQL
- PolarDB MySQL
- PolarDB PostgreSQL
- PolarDB O Edition
- The database instances that you want to manage are connected to DAS. For more information about how to connect database instances to DAS, see Access an Alibaba Cloud database instance and Access other self-managed database instances.
View the slow query log statistics of a single instance
- Log on to the DAS console.
- In the left-side navigation pane, click Instance Monitoring.
- Find the database instance that you want to manage, click Performance in the Actions column, and then click Slow Logs. The page that displays detailed slow query log information for the instance appears.
- On the Slow Log Analysis tab, you can use one of the following methods to view the slow query log trend:
- Click Last 15 Minutes, 30 Minutes, or 1 Hour to view the slow query log statistics within the last 15 minutes, the last 30 minutes, or the last hour.
- Specify a start time and an end time and click Search to view the slow query log statistics within the specified time range. The time range
cannot exceed 24 hours. Only the slow query log statistics generated within the last
30 days can be queried.
Note By default, the slow query log trend within the last 15 minutes is displayed.
- In the Slow Log Trend section, click a point in time in the line chart. Then, you can view the statistics and details about the slow query log data at that point in time.
- On the Slow Log Statistics tab, you can use one of the following methods to troubleshoot a slow SQL query:
- Click Sample in the Actions column to view the details about a sample slow SQL query.
- Click Optimize in the Actions column to view the diagnosis results and suggestions.
Note You can also click Database Expert Service to purchase the expert service. Database Expert Service provides value-added professional database services, such as emergency solutions, health diagnostics, performance optimization, security assurance, and data migration.
Export slow query log information
You can click Export Slow Log to download the slow query log information.
View the global slow query log trend
If you have multiple database instances, you can view the global slow query log trend for these instances and the analysis results of slow query log information for the top 10 instances on the Global Slow Log Trend page.
- Log on to the DAS console.
- In the left-side navigation pane, click Request Analysis, and then click Slow Logs. On the page that appears, you can view statistics in the Global Slow Log Trend and Top Instance Statistics sections.