Updated on 2024-04-03 GMT+08:00

Creating a SQL Insights Task

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.

Constraints

  • You need to enable Collect All SQL Statements before using SQL Insights.
  • After Collect All SQL Statements 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 is discarded by default.

    In RDS for MySQL 5.7.33.3 and later minor versions, you can set the rds_sql_tracer_reserve_big_records parameter to ON (which indicates that SQL statements containing more than 4,096 bytes are stilled recorded) on the Parameters page to remove this constraint. For details, see Modifying Parameters of an RDS for MySQL Instance. RDS for MySQL 5.6 and 8.0 do not support this parameter.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the DB instance name.
  5. In the navigation pane, choose DBA Assistant > Historical Diagnosis.
  6. Click SQL Explorer and then SQL Insights.
  7. Click next to Collect All SQL Statements.

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

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

    Figure 1 Log settings

  8. Click Create Task. In the displayed dialog box, specify Time Range, Dimension, and other configuration items, and click OK.

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