SQL Explorer
After Collect All Query Logs is enabled, you can filter, search for, and analyze SQL statements in multiple dimensions on the SQL Explorer page. Top SQL helps you locate exceptions.
SQL Explorer can record all SQL statements executed on your instance and enables you to analyze and search for the tables that are accessed and updated the most frequently and the SQL statements that have the longest lock wait.
Usage Notes
- After Collect All Query Logs is disabled, new SQL statements will not be collected and the collected SQL statements will be deleted.
- 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 automatically.
Execution Duration Distribution of Top SQL Templates
- Log in to the console.
- Click
in the upper left corner and select a region and project. - Click
in the upper left corner, and under Databases, click Data Admin Service. - In the navigation pane, choose Intelligent O&M > Instance List.
Alternatively, on the Overview page, click Go to Intelligent O&M.
- In the upper right corner of the Instance List page, search for instances by engine type, instance name, or instance IP.
- Locate the target instance and click Details.
- Choose SQL > SQL Explorer.
- Toggle on Collect All Query Logs to obtain information about all SQL statements executed on the current instance.
Collect All Query Logs takes effect once it is enabled.
- On the Top SQL tab page, view execution duration of top SQL statements.
You can select Last hour, Last 3 hours, or Last 6 hours to view execution durations of top SQL statements. You can also set a time range that spans no more than one day.
The execution duration distribution displays the execution duration distribution of all SQL statements within the selected time range. The duration ranges are as follows:
- < 100 ms: SQL statement executions when the duration is less than 100 ms
- 100 ms–500 ms: SQL statement executions when the duration is greater than or equal to 100 ms and less than 500 ms
- 500 ms–1s: SQL statement executions when the duration is less than 1s and greater than or equal to 500 ms
- > 1s: SQL statement executions when the duration is greater than 1s
SQL statistics in the four elapsed time lengths are collected over the time range you specified.
- If you select Last hour, SQL statement executions are calculated every 10 seconds.
- If you select Last 6 hours, SQL statement executions are calculated every minute.
- If you select a time range longer than 6 hours, SQL statement executions are calculated every 5 minutes.
Select By instance or By node to view execution duration distribution. You can change node to view its execution duration distribution. The primary node is selected by default. If you want to view the execution duration distribution of other nodes, click Change Node.
- In the SQL template list, 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 statements at that time.
- Specify a time range using your mouse on the graph, and you will see top SQL statements during that time range.
- Click Export to export details about all top SQL templates in the list. This function is available only to paid instances.
- In the SQL template list, locate a SQL template and click Details to view such as the total execution, average rows scanned, and average execution duration.
SQL Audit
- Log in to the console.
- Click
in the upper left corner and select a region and project. - Click
in the upper left corner, and under Databases, click Data Admin Service. - On the Overview page, click Go to Intelligent O&M.
- Locate the target instance and click Details.
- Choose SQL > SQL Explorer.
- Click the SQL Audit tab.
- On the SQL Audit tab page, view SQL audit tasks.
- Specify the start time, end time, task creation time, and node information to search for SQL audit tasks.
- Click Add SQL Audit Task and specify a time range to add a task. You can add an instance- or node-level task based on your service requirements. The added SQL audit task is displayed in the list below.
- Click Details in the Operation column to view task details. You can specify filters such as Time Range, User, Keyword, or Database and click Query to search for the SQL statements executed on the current instance. The selected time range must be after the time when the SQL audit task is added.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot