tencent cloud

Querying and Downloading Slow Query Logs
Last updated:2026-02-02 12:11:48
Querying and Downloading Slow Query Logs
Last updated: 2026-02-02 12:11:48
The slow query log is used to record queries in SQL Server whose execution time exceeds the specified threshold. Through the slow query log, you can identify which queries have low execution efficiency for optimization purposes. Typically, the SQL Server slow query log is SQL statements for troubleshooting issues and an important feature for checking the current SQL Server performance. This article introduces you to Querying and Downloading slow query logs via the console.
Note:
The log time defaults to Beijing time. If the default time zone is modified, the storage time of log data will be displayed in the time zone of the instance server, while the console will show Beijing (UTC+8) time.

SQL Server Slow Queries Related Instructions

The collection of slow query logs is enabled by default, and disabling it is not supported.
The threshold for slow query log collection is 1,000 milliseconds (namely, 1 second) by default, which indicates that SQL queries will be logged as slow queries when their execution time exceeds 1,000 milliseconds. Modification of the threshold (1,000–60,000 milliseconds) for slow query log collection is supported.
The slow query log file is collected every 5 minutes by default, indicating that all SQL queries with execution time exceeding the threshold for slow query collection within 5 minutes will be logged.
The retention period for slow query logs defaults to 7 days, and they will be automatically deleted upon expiration.

Slow Query Log File Generation and Download Policy

You can download slow query log files to view log data for troubleshooting issues. Before downloading files, you can learn about the policy for file generation and downloading as described below to perform Querying and Downloading files more efficiently.
When the instance reaches the collection frequency for slow query logs and slow query log data is generated, the console will generate slow query log files and supports downloading them.
When the instance reaches the collection frequency for slow query logs but no slow query log data is generated, the console will not generate slow query log files nor support downloading them.
When the instance has not reached the collection frequency for slow query logs but slow query log data is generated, you can click the Download button to generate slow query log files and download them.
When the instance has not reached the collection frequency for slow query logs and no slow query log data is generated, slow query log files cannot be generated by clicking the Download button, nor is downloading supported.

Slow Log File Field Descriptions

Field Name
Description
client_app_name
Client Application Name.
client_hostname
Client Hostname.
cpu_time
CPU time consumed by Remote Procedure Calls (RPC), unit: microseconds.
duration
Time required to complete Remote Procedure Calls (RPC), unit: microseconds.
last_row_count
The number of rows returned by the last executed SQL statement.
line_number
Line number of the SQL statement in the source file.
logical_reads
The number of logical reads performed during execution.
offset
The starting offset of the SQL statement in the source file.
offset_end
The ending offset of the SQL statement in the source file.
parameterized
Indicates whether the SQL statement has been parameterized.
physical_reads
The number of physical reads performed during execution.
row_count
The number of rows returned.
spills
The number of pages written to the database by overflow during query execution.
sql_text
The text content of the SQL statement.
statement
The SQL statement that is executed.
username
Username performing the operation.
writes
The number of writes performed during query execution.
connection_reset_option
Options for resetting the connection. This section applies only to reset connection RPC.
client_connection_id
Optional identifier provided by the client during connection.
data_stream
Binary stream for replay tracing of Remote Procedure Call.
database_name
Database name.
object_name
Object name referenced by the remote procedure call.
output_parameters
Output parameters returned from the remote procedure call.
query_plan_hash
Query plan hash, which can be used to identify similar query execution plans. You can use the query plan hash to locate queries with similar execution plans and determine their accumulated cost.
result
Return value of the remote procedure call.

Operation Steps

Setting the Threshold for Slow Query Log Collection

1. Log in to the SQL Server console.
2. Select the region above, find the instance that needs to be queried or to download slow query logs, and click Instance ID or click Manage in the Operation column to go to the instance management page.
3. On the instance management page, choose Operation Log > Operation Log Settings.

4. Set the Collection Threshold in the pop-up window and click Save.
Note:
The default value for the slow query log collection threshold is 1000 ms. Please adjust it according to actual requirements.
If it is required to set up blocking and deadlock event collection during the operation process, see Querying and Downloading Blocking and Deadlock Events.


Querying and Downloading Slow Query Log

1. Log in to the SQL Server console.
2. Select the region above, find the instance that needs to be queried or to download slow query logs, and click Instance ID or click Manage in the Operation column to go to the instance management page.

3. On the instance management page, choose Operation Log > Slow Query Log to view the slow query log list.
The supported fields include: File Name, Start Time, Last Updated Time, File Size, Operation (Download).
Supports searching slow logs based on time range: last 5 minutes, last 15 minutes, last 30 minutes, last 1 hour, last 3 hours, last 24 hours, today, yesterday, last 3 days, last 7 days, last 30 days, and custom time period.

4. In the Operation column, click Download to download the slow query log file.
Note:
When Download is clicked, the following scenarios may occur.
If the file status is "Completed", after clicking Download, you can copy the private network address and run the command to download it. The command format is: wget -c 'File download address' -O 'Custom filename', or download it locally.
If the file status is "Writing", when the file is not ready, clicking Download will display a message "Log file is being prepared" and downloading is unavailable. When the file is ready, you can copy the private network address and run the command to download it. The command format is: wget -c 'File download address' -O 'Custom filename', or download it locally.

Related APIs

API
Description
The interface (DescribeSlowlogs) is used to obtain slow query log file information.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback