Database Autonomy Service (DAS) automatically analyzes SQL statements and returns optimization suggestions with expected performance gains — so you can decide whether to apply them. Use this feature for slow SQL troubleshooting, pre-release code reviews, and routine self-checks.
Prerequisites
Before you begin, make sure that:
The database engine is one of the following:
RDS for MySQL — Basic and Cluster editions are not supported
MyBase MySQL
PolarDB for MySQL — single-node clusters (formerly standalone instances) are not supported
PolarDB-X 2.0 — instances with major version
5.4.13and minor version in the range[16415631, 16504348]are not supported. To check your version, see View and upgrade an instance versionMongoDB
The instance is connected to DAS. See Introduction to instance connection
The instance's accessed state is Normal Access
Limitations
SQL statements that use X-Engine tables cannot be diagnosed or optimized.
In PolarDB-X, when a SQL statement runs using a prepared statement, the slow query log records the statement template (for example,
select * from test where a = ? and b = ?) and the bound parameters (for example,params: [1, 2]) separately. Because this format is not a directly executable SQL statement, features that rely on the original statement for analysis or optimization may be limited.
Optimize SQL from the Slow Log Analysis page
SQL optimization on the Slow Log Analysis page is supported only for RDS for MySQL 5.6, 5.7, and 8.0 and PolarDB for MySQL 5.6, 5.7, and 8.0.
Log on to the DAS console.
In the left navigation pane, choose Intelligent O&M Center > Instance Monitoring.
Find the target instance and click the instance ID to open the instance details page.
In the left navigation pane, choose Request Analysis > Slow Logs.
On the Slow Log Analysis page, find the SQL statement to optimize:
On the Slow Log Statistics tab, find the target SQL template and click Optimize in the Actions column.
On the Slow Log Details tab, find the target SQL statement and click Optimize in the Actions column.
In the dialog box that appears, click Create Plan.
Select an execution node type:
Node type Description When to use Standby Node (Default) Secondary node of the current instance Routine query analysis Event Node Business node where the SQL statement was executed Troubleshooting and optimization Click Confirm Creation.
DAS generates a visual execution plan for the selected SQL statement.
Read the visual execution plan
Optimize SQL from the Instance Sessions page
SQL optimization on the Instance Sessions page is not supported for self-managed MySQL, MongoDB, or RDS for PostgreSQL instances.
Log on to the DAS console.
In the left navigation pane, choose Intelligent O&M Center > Instance Monitoring.
Find the target instance and click the instance ID to open the instance details page.
In the left navigation pane, click Instance Sessions.
In the Instance Sessions area, find the session to optimize and click Optimize.
In the SQL Diagnostic Optimization dialog box, review the diagnosis results. DAS diagnoses the SQL statement based on its complexity, the data volume of the related table, and the database load. Diagnosis may take more than 20 seconds. After diagnosis completes, DAS shows the results, optimization suggestions, and expected performance gains.
To apply the suggestion, click Copy in the upper-right corner and paste the optimized SQL statement into your database client or Data Management (DMS) to run it. To discard the suggestion, click Cancel.
View SQL diagnosis history
Log on to the DAS console.
In the left navigation pane, choose Intelligent O&M Center > Instance Monitoring.
Find the target instance and click the instance ID to open the instance details page.
In the left navigation pane, click Request Diagnostic History.
The history shows all past diagnosis records for the current instance, including the SQL content, diagnosis status, diagnosis time, and diagnosis results.