Updated on 2024-05-21 GMT+08:00

SQL Insights

Scenarios

The SQL Insights function 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 a 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 GaussDB(for MySQL) DB Instance.

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, choose Databases > GaussDB(for MySQL).
  4. On the Instances page, click the DB instance name to go to the Basic Information page.
  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.

    • 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.

  8. Click Create Task and specify Time Range, Dimension, Username, Keyword, Database, Thread ID, SQL Type, and Execution Status.

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

    Figure 1 Creating a SQL insights task

  9. Click OK.
  10. In the task list, click Details in the Operation column to view task details.
  11. Specify conditions such as Time Range, User, Keyword, Database and click Query. The selected time range must be after the time when the new task is added.