Database Autonomy Service (DAS) analyzes slow query logs to identify SQL statements that exceed a specified execution time threshold and provides optimization suggestions to help you resolve performance issues.
Prerequisites
The target instance must use the ApsaraDB RDS for PostgreSQL database engine.
ApsaraDB RDS for PostgreSQL Basic Edition instances are not supported.
Background information
Slow query logs are generated by the database kernel. Configuration parameters and thresholds vary by database engine. For details, see the official documentation for your database engine.
Procedure
Log on to the DAS console.
In the navigation pane on the left, click .
Find the target instance and click the instance ID to open the instance details page.
In the left-side navigation pane, click Request Analysis > Slow Logs.
On the Slow Log Analysis tab, select a time range and view the Slow Log Trend, Event Distribution, Slow Log Statistics, and Slow Log Details for that time range.
In the Slow Log Trend chart, you can select a point in time to view the Slow Log Statistics and Slow Log Details for that time.
NoteIf a slow SQL statement is too long to be fully displayed, you can hover the mouse pointer over the statement to view the complete SQL statement in a pop-up box.
On the Slow Query Log Statistics and Slow Query Log Details tabs, you can click
to save the slow query log information to your computer.You can click
to go to the OpenAPI Explorer console. The currently selected and entered parameters are automatically carried over for API debugging.In the Event Distribution area, you can query for slow log events within a specified time range. Click an event to view its details.
In the Slow Log Statistics section:
At the top of the list, select filter conditions to narrow down the data.
Click Details in the Actions column of the target SQL template to view its Slow Log Sample .
Click Optimize in the Actions column of the target SQL template to view the diagnosis results in the SQL Diagnostic Optimization dialog box.
If you accept the suggestion, click Copy in the upper-right corner and paste the optimized SQL statement into your database client or Data Management (DMS) to execute it.
NoteDAS performs SQL diagnostics based on SQL complexity, table data volume, and current database workload. The process may take more than 20 seconds. After the diagnosis is complete, DAS provides results, optimization suggestions, and the expected performance improvement. Use these results to decide whether to accept the suggestions.
In the Slow Log Details section, click Optimize in the Actions column for the target SQL statement to run a SQL Diagnostic Optimization.
Related documents
You can enable automatic SQL optimization to let DAS diagnose and optimize slow SQL queries as they occur. For more information, see automatic SQL optimization.