Overview
A 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 administrator (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 log details, error log details, rollback logs, log shipping, and scale-out history of instances on the operation log page in the console. You can also download slow logs. You can also view and download database logs on the command line interface (CLI) or through TencentDB APIs. For more information, see DescribeSlowLogs and DescribeBinlogs. Note:
TencentDB for MySQL single-node (cloud disk) instances and cluster edition instances do not support slow log download, rollback, and log shipping features. Cluster edition instances also do not support viewing the scale-out history.
Notes on MySQL slow queries
long_query_time: Slow query threshold parameter that is accurate to the microsecond level. The default value is 1 second. When a SQL statement takes more time than the threshold 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 1s, slow logs will be reported for exceeding queries; after this value is modified to 2s, the previously reported logs will still be displayed.
log_queries_not_using_indexes: Whether to log unindexed queries. The default value is OFF.
The Directions
Note:
If the read-only analysis engine is enabled for an instance, slow SQL statements will appear when data is loaded into the read-only analysis engine for the first time because the data is pulled from a read-write instance. Ignore the slow SQL statement information generated under the "txsqlPlugins_analytics_repl" account.
For cluster edition instances, you can select a specific node of an instance to query both slow log details and error log details on the operation log page.
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 instance management page, click the Operation Log tab to view the slow log details, error log details, rollback logs, log shipping, and scale-out history of the instance. You can also download slow logs.
|
Slow Log Details | Records SQL statements that took more than 1 second to execute in the database for the past month |
Download Slow Log | Downloads slow logs |
Error Log Details | Records the detailed information of each startup and shutdown as well as all the serious warnings and errors during operation |
Rollback Log | Records the status and progress of rollback tasks |
| Collects data from slow logs and error logs sourced from TencentDB for MySQL instances, and deliver them to the Cloud Log Service (CLS) for analysis |
Scale-out History | Records elastic CPU scale-out operations of the instance. |
3. On the Download Slow Log tab, click Download in the Operation column to download slow logs.
4. We recommend that you copy the download address in the pop-up window, log in to a (Linux) CVM instance in the same VPC as the TencentDB instance, and run the wget command to download over the private network at a higher speed. For more information, see Customizing Linux CVM Configurations. Note:
Logs with a size of 0 KB cannot be downloaded.
You can also click Download to download it directly. However, this may take a longer time.
wget command format: wget -c 'log file download address' -O custom filename.log
Below is a sample:
wget -c 'http://szx.dl.cdb.tencentyun.com:303/cfdee?appid=1210&time=1591&sign=aIGM%3D' -O test.log