Updated on 2023-03-07 GMT+08:00

SQL Explorer

Precautions

  • After SQL Explorer is disabled, DAS will stop collecting new SQL statements and delete collected SQL data.
  • SQL Explorer cannot record all data. As for MySQL, it has the following constraints:
    • Some data cannot be recorded if a buffer overrun occurs.
    • Any SQL statement that exceeds 4096 bytes is discarded by default.

      This constraint can be specified by setting parameter rds_sql_tracer_reserve_big_records in MySQL 5.7.33.3 or later. For example, you can set the parameter to ON on the RDS instance parameter setting page, indicating that SQL statements whose length exceeds 4096 bytes are stilled recorded.

Procedure

  1. Log in to the DAS console.
  2. On the Overview page, click Go to Intelligent O&M.
  3. Select the required instance and click Details.
  4. Choose SQL > SQL Explorer to view SQL Explorer details of the instance.
  5. Toggle on Enable DAS SQL Explorer to obtain information about all SQL statements executed on the current instance.

    • SQL Explorer takes effect once it is enabled.

  6. Click the TOP SQL tab, select Last 1 hour, Last 3 hours, or Last 6 hours or specify a time range spanning no more than one day, to view the top SQL statements executed.

    Execution Duration Distribution displays the distribution of the time required to execute all SQL statements in a specific time period. There are four execution duration ranges. The system calculates execution times of the SQL statements in each execution time range. If you select Last 1 hour, the execution durations are calculated every 10 seconds. If you select Last 6 hours, the execution durations are calculated every 1 minute. If you select a time range longer than 6 hours, the execution durations are calculated every 5 minutes. The execution duration ranges of SQL templates are as follows:

    • < 100 ms
    • 100 ms—500 ms
    • 500 ms—1s
    • > 1s

  7. Select By instance or By node. If you select By node, the execution duration distribution of the primary node is displayed by default. To view the duration distribution of other nodes, click Change Node.
  8. Use either of the following method to view execution duration details, such as average execution duration, total duration, average lock wait duration, and average scanned rows.

    • Hover your mouse at any point in time on the graph to view top SQL templates at that time.
    • Specify a time range using your mouse on the graph, and you will see top SQL templates used during that time range.

  9. In the SQL template list, locate a SQL template and click Details to view total executions, average rows scanned, average execution duration, and the like.
  10. In the SQL template list, locate a SQL template and click Diagnose to view details such as the execution plan, suggestions for tuning indexes and SQL statements.
  11. On the SQL Audit page, specify data collection time, task creation time, and node information to search for SQL audit tasks.
  12. Click Add SQL Audit Task and specify a time range to add a task. You can add instance- or node-level task based on your service requirements.
  13. Locate the added task in the lower part.
  14. Click View Detail in the Operation column to view task details.
  15. Specify conditions such as Time Range, User, Keyword, Database and click Query. The selected time range must be after the time when the SQL audit task is added.