Viewing Slow Query Logs
Scenarios
Slow query logs record statements that exceed long_query_time (10 seconds by default). You can view log details and statistics to identify statements that are executing slowly and optimize the statements.
- SELECT
- INSERT
- UPDATE
- DELETE
- CREATE
- ALTER
- DROP
Parameter Description
Parameter |
Description |
---|---|
long_query_time |
Specifies how many seconds a SQL query has to take to be recorded in slow query logs. The default value is 10s. You are advised to set this parameter to 1s. The lock wait time is not calculated into the query time. |
log_queries_not_using_indexes |
Specifies whether to record the slow query that without indexes. The default value is OFF. |
log_throttle_queries_not_using_indexes |
Specifies the SQL statement that can be written to the slow query log every minute. The default value is 0. |
Viewing Log Details
- Log in to the management console.
- Click in the upper left corner and select a region and a project.
- Click in the upper left corner of the page, choose .
- On the Instances page, click the instance name to go to the Basic Information page.
- In the navigation pane on the left, choose Logs.
- On the Slow Query Logs page, view the slow query log details.
- View slow query logs of different nodes in a given database and SQL statement types. In the upper right corner of the page:
Enter a database name, click the drop-down list, and select your desired node.
Click the drop-down list and select a SQL statement type (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, or DROP).
Click and specify a time period.
Figure 1 Viewing slow query logs
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.