All Products
Search
Document Center

ApsaraDB RDS:View slow query logs

Last Updated:Jun 21, 2026

This topic describes how to view the slow query log details for an ApsaraDB RDS for MySQL instance. It also covers common issues, including SQL logging criteria, statement truncation, timestamp discrepancies, and differences in log entry counts.

Overview

The slow query log feature for ApsaraDB RDS for MySQL is enabled by default. For more information, see Collection policy for ApsaraDB RDS for MySQL slow query logs. To view other types of logs, see View error logs and slow query logs.

Usage notes

  • If an instance generates more than 600 slow query log entries within one minute, some entries may be lost. You can mitigate this issue by upgrading the minor engine version to 20191212 or later.

  • If an SQL statement exceeds 8,192 bytes, the slow query log truncates the statement. The same limitation applies to SQL Explorer. You cannot change this 8,192-byte truncation limit. To get the complete SQL statement, retrieve the full request from your application.

Query logs on the Slow Log Analysis page

  1. Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.

  2. In the left-side navigation pane, choose Autonomy Services > Slow Query Logs.

  3. On the Slow Log Analysis tab, select a time range to view the corresponding slow query log statistics and details.

    Note

    You can also go to the Logs page from the instance details page and view slow query log details on the Slow Log Details tab.

    Important
    • The slow query log details include information such as SQL statement, access source, database, and execution time. The collection time for a slow query log is recorded differently based on the minor engine version. In earlier versions, this timestamp indicated the query's end time. Starting from minor engine version 20211231 (for MySQL 5.7.35) and 20220530 (for MySQL 8.0.25), the timestamp indicates the query's start time.

    • To export slow query log details, see Slow Log Analysis.

FAQ

SQL logging criteria

  • Based on execution time: SQL statements with an execution time that exceeds the threshold specified by the long_query_time parameter are recorded in the slow query log. The default value is 1 second. This means that, by default, queries running longer than 1 second are recorded.

  • Based on index usage: If the log_queries_not_using_indexes parameter is set to ON, SQL statements that do not use an index are recorded in the slow query log, even if their execution time does not exceed the long_query_time threshold. By default, the log_queries_not_using_indexes parameter is set to OFF.

Execution time discrepancy

This discrepancy can occur if the time zone changed during the SQL statement's execution. The time zone for slow query log timestamps can be set at the session, database, or system level.

If a database has a specific time zone, that time zone is used; otherwise, the system time zone is used. If an SQL statement modifies the session-level time zone, the time zone conversion for the slow query log might fail, causing a time difference.

Unlogged slow queries

If you observe a session in SHOW PROCESSLIST whose execution time exceeds the slow query log threshold but it does not appear in the log, this is usually because the SQL statement was terminated (killed), either manually or automatically. In this case, the SQL statement is not recorded in the slow query log details.