Updated on 2024-07-17 GMT+08:00

Slow Query Logs

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, client IP address, or SQL template. It helps you quickly identify bottlenecks and improve instance performance.

Procedure

  1. Log in to the management 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 box containing your target instance and click Details.
  7. Choose SQL > Slow Query Logs.

    You can click to enable Collect Slow Query Logs.

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

    On the SQL Query Logs tab page, you can 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. You can view slow query logs over time, as well as slow query log statistics and details.

    • The Slow Queries over Time chart displays slow query logs in the specified time period.
      Figure 2 Slow queries over time
    • Statistics shows slow query logs by node, SQL statement type, database, data table, user, and client.
      Figure 3 Slow query log statistics
    • Slow query log details include the execution completion time, SQL statement, SQL statement type, database, database table, client IP address, user, execution duration, lock wait time, scanned documents, returned documents, and scanned indexes.
      Figure 4 Slow query log details

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