Updated on 2025-10-16 GMT+08:00

SQL Insights

Scenarios

SQL Insights allows you to not only query all executed SQL statements, but also analyze and search for the tables that are accessed and updated most frequently, and the SQL statements that have the longest lock wait, helping you quickly identify exceptions.

To use this function, submit a service ticket to request required permissions.

Constraints

  • You need to enable Collect All Query Logs before using SQL Insights.
  • After Collect All Query Logs is disabled, new SQL statements will not be collected anymore and the collected SQL data will be deleted.
  • If there is a buffer overrun, some data cannot be recorded.
  • Any SQL statement that exceeds 4,096 bytes will not be recorded by default.

Procedure

  1. Click in the upper left corner and select a region.
  2. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  3. On the Instances page, click the DB instance name to go to the Overview page.
  4. In the navigation pane, choose SQL Analysis and Tunning under DBA Assistant.
  5. Click the SQL Insights tab.
  6. Click next to Collect All Query Logs.

    To disable this function, click Log Settings in the upper right corner, toggle off the Collect All Query Logs switch, and click OK.

    Collecting all SQL statements generates a performance loss of no more than 5%.

    Figure 1 Log settings

  7. Click Create Task. In the displayed dialog box, specify Time Range, whether to synchronize to other instances, and other configuration items, and click OK.

    Figure 2 Creating a SQL Insights Task

  8. In the task list, click Details in the Operation column to view task details.