Updated on 2024-11-06 GMT+08:00

Creating an 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.
  • Some data cannot be recorded if a buffer overrun occurs.
  • If the length of an SQL statement exceeds the value of rds_sql_tracer_max_record_size, the statement is not recorded by default.

    To configure the parameter value, see Modifying Parameters of a DB Instance.

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 of the page and choose Databases > GaussDB(for MySQL).
  4. On the Instances page, click the instance name.
  5. In the navigation pane, choose DBA Assistant > Historical Diagnosis.
  6. Under the SQL Explorer tab, click SQL Insights.

    Click next to Collect All SQL Statements.
    • Collecting all SQL statements generates a performance loss of no more than 5%.
    • To disable this function, click Log Settings in the upper right corner, toggle off the Collect All SQL Statements switch, and click OK.

  7. Click Create Task.

    Figure 1 Creating an SQL insights task

  8. On the displayed page, set Time Range, Synchronization to Other Instances, Dimension, Username, Keyword, Database, Thread ID, SQL Type, and Status.

    You can set Dimension to Instance or Node. When Node is selected, you can view the SQL logs of deleted nodes.

    Figure 2 Creating an SQL insights task

  9. Click OK.
  10. In the task list, click Details in the Operation column to view task details.
  11. Select a keyword such as Time Range, Username, Keyword, or Database to search for the SQL statements executed on the current instance or node.

    The selected time range must be after the time when the new task is added.