An SQL statement query that takes more time than the specified value is referred to as a "slow query", and the corresponding statement is called a "slow query statement". The process where a database admin (DBA) analyzes slow query statements and finds out the reasons why slow queries occur is known as "slow query analysis".
You can view the slow logs details, error logs details, and rollback logs of an instance, and download slow logs on the operation log page in the console. You can also view and download database logs through the command line interface (CLI) or TencentDB APIs. For more information, see DescribeSlowLogs and DescribeBinlogs.
Note
Currently, slow log download and rollback features are not supported for TencentDB for MySQL single-node instances of the cloud disk edition.
Notes on slow queries in MySQL
long_query_time: slow query threshold parameter down to the microsecond level. The default value is 10s. When a SQL statement takes more time to execute, it will be recorded in a slow log.
When the long_query_time parameter is adjusted, existing slow logs will not be affected. For example, if the slow log threshold parameter is 10s, slow logs will be reported for exceeding queries; after this value is modified to 1s, the previously reported logs will still be displayed.
log_queries_not_using_indexes: whether to log unindexed queries. The default value is OFF.
Instructions
1. Log in to the TencentDB for MySQL console. In the instance list, click an instance ID or Manage in the Operation column to enter the instance management page.
2. On the Operation Log tab, you can view the slow logs details, error logs details, and rollback logs of the instance and download slow logs.
Feature
Note
Slow Log Details
Records SQL statements that took more than 10s to execute in the database in the past month
Slow log download
Downloads slow logs
Error Log Details
Record the detailed information of each startup and shutdown as well as all the serious warnings and errors during operation
Rollback logs
Records the status and progress of rollback tasks
3. On the Download Slow Log tab, click Download in the Operation column to download slow logs.