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, an ApsaraDB RDS for MySQL instance is used.

Prerequisites

  • DAS provides the slow query log analysis feature only for the following types of database instances:
    • ApsaraDB RDS for MySQL
    • ApsaraDB RDS for PostgreSQL
    • ApsaraDB PolarDB MySQL-compatible edition
    • ApsaraDB PolarDB PostgreSQL-compatible edition
    • ApsaraDB PolarDB O Edition
    • Redis
    • MongoDB
  • A database instance is connected to DAS. For more information, see Connect Alibaba Cloud database instances to DAS and Connect other database instances to DAS.

View the slow query log statistics of a single database instance

  1. Log on to the DAS console.
  2. In the left-side navigation pane, click Instance Monitoring.
  3. Find the database instance, click Performance in the Actions column, and then click Slow Logs. The page that displays detailed slow query log information for the instance appears.
  4. 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.
  5. 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.
  6. On the Slow Log Analysis tab, you can use one of the following methods to view the slow query log trend:
    • 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 the database instances and the analysis results of slow query log information for the top 10 database instances on the Global Slow Log Trend page.

Note DAS provides the global slow query log trend feature only for self-managed MongoDB instances, ApsaraDB RDS for MySQL instances, self-managed MySQL instances, ApsaraDB for Redis instances, and self-managed Redis instances.
  1. Log on to the DAS console.
  2. 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.