The slow log is used to record query statements that take more time than the specified value to execute in TDSQL-C for MySQL read-write and read-only instances. You can find out inefficient query statements to optimize by slow log details. TDSQL-C for MySQL allows you to download such details for easier analysis and optimization.
This document describes how to query and download slow log details.
Querying Slow Logs
1. On the cluster list page, follow the steps below to enter the cluster management page based on the actual view mode.
Log in to the TDSQL-C for MySQL console, and click the target cluster in the cluster list on the left to enter the cluster management page. 2. Select a region at the top, locate the cluster for which you want to query or download slow logs, and click the Cluster ID or Manage in the Operation column to enter the cluster management page.
2. On the cluster management page, select the Operation Log tab, choose the target instance, and then click Slow Log Details .
In the slow log details list, you can query the details of all slow logs or logs of today, yesterday, the last 7 days, the last 30 days, or a custom time range.
You can query slow log details by key fields (client address, username, and database name) to quickly obtain target slow logs, and you can export them into a list file.
In the slow log details list, you can view detailed information. For specific fields, refer to Slow Log Fields. Note:
To view the following 7 fields: number of remote reading times, number of remote read bytes, time spent on remote reading (ns), number of remote writing times, number of remote written bytes, time spent on remote writing (ns), and transaction submission delay (μs), your kernel version should be TXSQL 8.0 with a kernel minor version of 3.1.12 or later. To display them in the slow log list, you can click the setting icon on the right, select the fields you want to view, and click OK .
When you download slow log details using the Export feature, all fields will be included in the downloaded details, even if not all fields are selected in the settings.
Slow Log Fields
|
Execution Time | Time of execution, for example, 2024/9/22 23:56:12. |
SQL Statement | The executed SQL statement, for example, DROP DATABASE IF EXISTS db1. |
Client Address | The client address where an operation was executed, for example, 172...10. |
Username | The username used to perform an operation, for example, root. |
Database | Database name, for example, mysql. |
Duration (sec) | SQL execution time, in seconds. |
Lock Time (sec) | Total time taken during an operation, from waiting for a lock to acquiring it and completing the operation, in seconds. |
Parsed Rows | Number of rows successfully parsed and processed during a query or an operation. |
Returned Rows | Number of rows actually returned to a client after a query or an operation. |
Number of remote reading times | Number of times data is read from the storage layer during a query or an operation. |
Number of remote read bytes | Amount of data read from the storage layer during a query or an operation, in bytes. |
Time spent on remote reading (ns) | Time taken to read data from the storage layer during a query or an operation, in nanoseconds. |
Number of remote writing times | Number of times data is written to the storage layer during a write operation. |
Number of remote written bytes | Amount of data written to the storage layer during a query or an operation, in bytes. |
Time spent on remote writing (ns) | Time taken to write data to the storage layer during a query or an operation, in nanoseconds. |
Transaction submission delay (μs) | Time elapsed from the beginning of a transaction submission to its actual completion, in microseconds. |
Downloading Slow Log Details
On the cluster list page, proceed based on the actual view mode.
1. Log in to the TDSQL-C for MySQL console, and click the target cluster in the cluster list on the left to enter the cluster management page. 2. On the cluster management page, select the Operation Log tab, choose the target instance, and then click Slow Log Details .
3. Query the target slow log details by time or keyword, and then click Export .
4. In the pop-up window, select a file format, and click OK for local download.
You can export the filtered or retrieved results. Export formats include CSV and native format (supported by open-source analysis tools).
Exporting in CSV format allows for quick check and optimization, making it user-friendly. An example of the exported information is as follows:
Exporting in native format allows for recognition by open-source analysis tools. An example of the exported information is as follows:
You can export up to 2,000 records at a time. To download more than 2,000 records, select a shorter time range and export a part of the records you need. Repeat the steps until all of the records are exported.
2. Select a region at the top, locate the cluster for which you want to query or download slow logs, and click the cluster ID or Manage in the Operation column to enter the cluster management page.
3. On the cluster management page, select the Operation Log tab, choose the target instance, and then click Slow Log Details .
4. Query the target slow log details by time or keyword, and then click Export .
5. In the pop-up window, select a file format, and click OK for local download.
You can export the filtered or retrieved results. Export formats include CSV and native format (supported by open-source analysis tools).
Exporting in CSV format allows for quick check and optimization, making it user-friendly. An example of the exported information is as follows:
Exporting in native format allows for recognition by open-source analysis tools. An example of the exported information is as follows:
You can export up to 2,000 records at a time. To download more than 2,000 records, select a shorter time range and export a part of the records you need. Repeat the steps until all of the records are exported.
Was this page helpful?