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.
You can download slow query logs.
- 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
Enabling Show Original Log
By default, SQL statements are displayed anonymously. If Show Original Log is enabled, SQL statements in the logs will be displayed in plaintext.
Logs displayed in plaintext will be automatically deleted 30 days later. If a DB instance is deleted, its related logs will also be deleted.
- 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 Slow Query Logs tab, click next to Show Original Log.
. On the Figure 2 Enabling Show Original Log
- In the displayed dialog box, click Yes.
Reporting Slow Logs to LTS
- 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, click next to Report Slow Log to LTS.
- Select an LTS log group and log stream and click OK.
Figure 3 Reporting slow logs to LTS
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