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

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.

Viewing Slow Query Logs

  1. Log in to the DAS 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.
  5. In the upper right corner of the Instance List page, search for instances by engine type, instance name, or instance IP.
  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.

    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.

      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.

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

      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.

      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.

      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 Storage and Archiving

  • Slow query log storage

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

  • Log archiving

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

    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.