All Products
Search
Document Center

SQL optimization

Last Updated: Aug 06, 2020

You can use the slow query log optimization feature to diagnose and optimize SQL statements.

This feature is only available to ApsaraDB RDS for MySQL databases and user-created MySQL databases. This topic uses ApsaraDB RDS for MySQL databases to demonstrate how to optimize SQL statements.

Prerequisites

Optimize SQL statements on the Slow Log Statistics tab

  1. On the Slow Log Statistics tab, find the target SQL template. Click Optimize in the Actions column.

    For more information about how to go to the Slow Log Statistics tab, see Analyze slow logs.

    Optimize

  2. In the SQL Diagnostic Optimization dialog box, click OK.Diagnose

    DAS performs SQL diagnosis based on the complexity of SQL statements, the amount of data in the table, and the database load. Suggestions may be returned in more than 20 seconds. After diagnosis, the SQL diagnosis engine will give diagnosis results, optimization suggestions and expected optimization benefits. You can determine whether to adopt the suggestions.

Optimize SQL statements on the Instance Sessions page

  1. On the Instance Sessions page, select the target SQL statement and click Optimize.

    For more information about how to go to the Instance Sessions page, see Instance sessions.

    Optimize SQL statements on the Instance Sessions page

  2. In the SQL Diagnostic Optimization dialog box, click OK.

  3. In the left-side navigation pane, click Request Diagnostic History to view the optimization history of the current instance, such as diagnosis start time and SQL statements.Request Diagnostic History