Database Autonomy Service (DAS) collects and analyzes SQL statements exceeding a specified execution threshold, tracks trends, and provides optimization suggestions to help resolve slow queries.
Limits
| Item | Limit |
|---|---|
| Log entry size | 16 KB per entry. Excess content is truncated. |
| Basic Edition support | RDS for MySQL Basic Edition instances can view and export slow query logs but do not support SQL diagnostics or optimization. |
Prerequisites
Ensure the following:
-
An RDS for MySQL instance is created.
-
(Optional) The
AliyunHDMFullAccesspermission is granted to your RAM user.
View and analyze slow query logs
-
Go to the Instances page. In the top navigation bar, select the region of your instance. Find the instance and click its ID.
-
In the left-side navigation pane, choose Autonomy Services > Slow Query Logs.
-
On the Slow Log Analysis tab, specify a time range. > Note: The end time must be later than the start time. Maximum range: 7 days. Data retained for the last month.
The page includes:
Slow Query Log Trends
A time-series chart of slow query distribution over the selected period. Click a data point to drill down into Slow Query Log Statistics and Slow Query Log Details.
Hover over a truncated SQL statement to see the full text.
Event Distribution
Distribution of slow query events.
Slow Query Log Statistics
Aggregated statistics grouped by SQL template. Available filters vary by database engine.
| Action | Description |
|---|---|
| Click the SQL ID | View SQL template details, including user distribution, client distribution, and metric trends. |
| Optimize | Run SQL diagnostics. DAS analyzes the statement based on complexity, table data volume, and workload. Diagnosis may take over 20 seconds. Results include optimization suggestions and expected improvements. |
| Throttling | Create an SQL throttling rule for the statement. |
| IMCI (PolarDB for MySQL only) | View IMCI (In-Memory Column Index) documentation for complex query acceleration. Appears when the PolarDB for MySQL instance has no IMCI node, Maximum Execution Duration exceeds 20 seconds, and Maximum Scanned Rows exceeds 200,000. |
Slow Query Log Details
Individual slow query records. Click Optimize or Throttling in the Actions column to diagnose or throttle a specific statement.
Click
to export slow log data.
Click
to populate parameters in the OpenAPI console for debugging.
Key metrics
| Metric | Description |
|---|---|
| Maximum Scanned Rows | Maximum rows scanned by slow queries in the selected time range. |
| SQL Template | A normalized query pattern for SQL statements of the same type. |
| Slow SQL Sample | A representative sample collected at regular intervals from an SQL template. Samples do not cover all entries. View details about the slow query logs. |
| Slow Log Details | Records of queries whose execution duration exceeds the long_query_time value. Slow query log analysis 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. MySQL slow query log documentation.
FAQ
Why does the execution completion time in slow query logs differ from the actual time?
This occurs when an SQL statement modifies the session-level time zone. Slow query logs record completion time based on the time zone hierarchy: session > database > system. If an SQL statement modifies the session time zone, the logged time may differ from the actual completion time.
References
-
Use the automatic SQL optimization feature — DAS automatically optimizes slow queries.
-
Use the automatic SQL throttling feature — DAS automatically throttles slow queries to protect database stability.