Updated on 2023-12-13 GMT+08:00

SQL Insights

SQL Insights allows you query all executed SQL statements, as well as 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 ensure stable database services.

Precautions

  • You need to enable Collect All SQL Statements before using SQL Insights. Collecting all SQL statements generates a performance loss of no more than 5%.
  • After Collect All SQL Statements is disabled, new SQL statements will not be collected anymore and the collected SQL data will be deleted.
  • Some data cannot be recorded if a buffer overrun occurs.
  • Any SQL data record containing more than 4,096 bytes is discarded by default.

    This constraint can be removed by setting parameter rds_sql_tracer_reserve_big_records for RDS for MySQL kernel versions 5.7.33.3 or later. RDS for MySQL 5.6 and 8.0 do not support this parameter. You can set the parameter to ON by referring to Modifying RDS for MySQL Instance Parameters, which means that SQL data records containing more than 4,096 bytes are stilled recorded.

  • Logs of all SQL statements executed on free instances can be retained for only one hour while those for paid instances can be retained for seven days by default and for up to 30 days as a maximum. After the retention period expires, the logs are deleted.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane, choose Intelligent O&M > Instance List.

    Alternatively, on the Overview page, click Go to Intelligent O&M.

  5. In the upper right corner of the Instance List page, search for instances by engine type, instance name, or instance IP.

    Figure 1 Searching for instances

  6. Locate the box containing your target instance and click Details.
  7. In the upper part of the page, click Go to New Version.

    Figure 2 Intelligent O&M

  8. Choose SQL > SQL Insights.

    Toggle on on the right of Collect All SQL Statements.

    Figure 3 SQL Insights

    You can also click Log Settings in the upper right corner of the page to enable Collect All SQL Statements.

    Figure 4 Configuring log settings

    Collect All SQL Statements takes effect once it is enabled.

    If you want to disable it, click Log Settings in the upper right corner and toggle off the switch.

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

    Figure 5 Creating a task

  10. In the task list, view the task you created.

    Figure 6 Viewing a task
    • Locate the row containing your task and click Details in the Operation column to view task details.
    • Locate your task and click View Syn Tasks in the Operation column to view synchronization task details.