Updated on 2025-06-24 GMT+08:00

Viewing Slow Query Logs

Slow query logs help you locate SQL statements that process a large amount of data, scan a large number of rows, or run for a long time, so that you can optimize them to improve database performance.

To use this function, you need to subscribe to Intelligent O&M first. For details, see Subscribing to Intelligent O&M.

If you did not subscribe to Intelligent O&M, you can view only the data of the last hour. The data will be automatically deleted when it expires.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the instance name to go to the Overview page.
  5. In the navigation pane, choose DBA Assistant > Historical Diagnosis.
  6. Click the Slow Query Logs tab.
  7. In the Slow Queries over Time area, you can view the slow query log and vCPU usage trends of your DB instance.

    You can view the Slow Queries over Time chart in the last 1 hour, last 3 hours, last 12 hours, or a custom time period (spanning no more than one day).

    Figure 1 Slow Queries over Time

  8. Click Archive History. In the archived slow query logs list, view slow query log details.

    The displayed details include the log start time, end time, and log file size.

    Figure 2 Archived Slow Query Logs

    Slow query logs are automatically archived every 3 minutes. To view the latest slow query logs, click Archive Now.

  9. In Top 5 Slow Query Logs area, view the top 5 slow SQL statements sorted by user or client IP address.

    Figure 3 Top 5 Slow Query Logs

  10. In the details list, view details about slow query logs.

    • You can filter slow query logs by SQL statement, database, client IP address, user, execution duration, and scanned rows.
    • To export the slow query log list, click Export.
    • To view log export history, click View Export List.