All Products
Search
Document Center

ApsaraDB RDS:Slow log analysis

Last Updated:Feb 27, 2026

Database Autonomy Service (DAS) analyzes SQL statements whose execution duration exceeds a specified threshold, surfaces execution trends and statistics, and provides optimization suggestions. Use this feature to identify and resolve slow queries that affect database performance and stability.

Limits

ItemLimit
Log entry size16 KB maximum per entry. Content that exceeds this length is truncated.
Basic Edition supportApsaraDB RDS for MySQL Basic Edition instances support viewing and exporting slow query logs but do not support SQL diagnostics or SQL optimization.

Prerequisites

Before you begin, make sure that you have:

  • An ApsaraDB RDS for MySQL instance

  • (Optional) The AliyunHDMFullAccess permission granted to your RAM user

View and analyze slow query logs

  1. Go to the Instances page. In the top navigation bar, select the region where your RDS instance resides. Find the instance and click its ID.

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

  3. On the Slow Log Analysis tab, specify a time range. > Note: The end time must be later than the start time. The maximum time range is 7 days. Slow query log data is available for the last month.

The page displays the following sections:

Slow Query Log Trends

A time-series chart showing the distribution of slow queries over the selected period. Click a point in the chart to drill down into the corresponding Slow Query Log Statistics and Slow Query Log Details.

If a slow SQL statement is too long to display in full, hover over it to see the complete statement.

Event Distribution

Shows the distribution of slow query events.

Slow Query Log Statistics

Aggregated statistics grouped by SQL template. The available filter conditions vary by database engine.

ActionDescription
Click the SQL IDView correlations and details for the SQL template, including user distribution, client distribution, and metric trends.
OptimizeRun SQL diagnostics. DAS analyzes the statement based on its complexity, the data volume of the related table, and the database workload. The diagnosis may take more than 20 seconds. After it completes, DAS provides a diagnosis result, optimization suggestions, and expected performance improvements.
ThrottlingCreate a throttling rule for the SQL statement. For more information, see SQL throttling.
IMCI (PolarDB for MySQL only)View In-Memory Column Index (IMCI) documentation to improve complex query performance on large datasets. This button appears when the PolarDB for MySQL instance has no IMCI node, the Maximum Execution Duration exceeds 20 seconds, and the Maximum Scanned Rows exceeds 200,000.

Slow Query Log Details

Individual slow query records. Click Optimize or Throttling in the Actions column to run SQL diagnostics or create a throttling rule for a specific statement.

Click image to export the slow log data locally.

Click image to populate the selected parameters into the OpenAPI console for API debugging.

Key metrics

MetricDescription
Maximum Scanned RowsThe maximum number of rows scanned during slow queries within the selected time range.
SQL TemplateA normalized query pattern generated for SQL statements of the same type.
Slow SQL SampleA representative sample collected from an SQL template at regular intervals. Samples do not cover all slow query logs. For a complete list, see View details about the slow query logs.
Slow Log DetailsDetailed records for queries whose execution duration exceeds the long_query_time parameter value. The slow query log analysis feature is enabled by default.

Log queries that do not use indexes

Enable the log_queries_not_using_indexes parameter to record SQL queries that do not use indexes, even when their execution duration is below the long_query_time threshold. For more information, see the MySQL slow query log documentation.

FAQ

Why does the execution completion time in slow query logs differ from the actual time?

This typically happens when an SQL statement modifies the session-level time zone. Slow query logs record execution completion time based on the time zone at three levels: session, database, and system. If a database-level time zone is set, that time zone is used. Otherwise, the system time zone applies. When a statement changes the session time zone, the recorded time may not match the actual execution completion time.

References