You need to enable JavaScript to run this app.
Database Workshop

Database Workshop

Copy page
Download PDF
Log management
Slow log details management
Copy page
Download PDF
Slow log details management
This topic describes how to view the analysis results of slow logs and download target slow logs on the Database Workshop (DBW) console.​
Prerequisites​
Precautions​
  • When you access the Slow log analysis tab through Operation observability on the left navigation bar, slow log information about the first instance in the Instance list is viewed by default.​
  • Default displays slow log information from the past 10 minutes, such as the number of slow SQL, CPU usage, and Slow SQL list.​
  • You can view slow log data for up to the past 30 days, with a maximum query time span of 7 days.​
  • The database proxy is enabled by default for the RDS for MySQL instance. Therefore, the connection pool may be reused, that is, one connection is shared by multiple clients, which may cause the IP source to be inconsistent with the actual IP address and port.​
  • When filtering to view slow SQL queries within a certain period, the query end time must be later than the start time.​
  • When you filter by time to view the number of slow SQL queries and CPU usage of an instance or read-only node within a specified time, the slow SQL list pane displays the database, execution user, IP source, average execution time(s), maximum lock wait time(s), average rows returned, and first wait time for each SQL template within the specified time.​
  • Index optimization suggestions:​
  • The index optimization suggestion function needs to sample and analyze the content of the database and table. Therefore, when you view the index optimization suggestion of SQL for the first time, you need to authorize DBW to read the database and table.​
  • It takes about 10 to 20 seconds to view SQL index optimization suggestions.​
  • Index optimization suggestions are based on sampling analysis of partial data in the table. The generated optimization suggestions are for reference only and need to be further evaluated based on the actual situation.​
  • When downloading slow logs, note the following:​
  • Up to 1 million slow log entries can be downloaded in a single request.​
  • Slow log download tasks are retained for 1 day by default. Expired tasks will be automatically deleted.​
  • When you select to download slow log details, you will get the slow SQL that can be executed directly.​
  • You can view and export slow log download files in Export history.​
  • Slow log files downloaded from the system are compressed in .gz (Gzip) format. For macOS users, please extract the downloaded file using the steps below:​
  • Decompress using the built-in gzip or gunzip command-line tools:Open the Terminal and run the gzip or gunzip commands provided by the system to extract the files. The command format is gzip -d your_filename.gz or gunzip your_filename.gz.​
  • To decompress the file using the tar tool: Download and install the tar tool to decompress the file. The command format is tar -xz --force-local -f file_name.gz.​
Query a slow log​
  1. Log on to the DBW console.​
  1. On the left navigation bar, select Operation and maintenance management > Observation and diagnosis.​
  1. On the top menu bar, select the region.​
  1. On the Observation and diagnosis page, click Log management.​
tip​
  • You can also switch to the target instance by searching for the instance ID.​
  • When you access the slow log analysis through Observation and diagnosis on the left navigation bar, information about the first instance in the Instance list is displayed by default.​
  1. On the Slow log tab, filter by the desired time frame and select the target node (such as the primary or secondary node) from the Node ID dropdown to view its slow log trend, statistical summary, and details, as shown below.​
tip​
  • If no Node ID is selected, the slow log information for all nodes is displayed by default.​
  • In the Node ID dropdown, each node shows the number of slow logs within the selected time frame:​
  • 0 article: Indicates no slow logs during this period, with normal system response, and performance bottlenecks can be ruled out.​
  • Greater than 0 article: Indicates potential performance issues. It is recommended to further analyze the specific slow SQL.​
  • When selecting a time range, the query end time must be later than the start time.​
  • View slow log trends: In the left area of the Slow log details tab, you can view the slow log trends within a certain period. You can also click a specific time point to view the Slow SQL number and CPU usage at that moment.​
  • View slow log statistics: On the right side of the Slow log tab, you can view the Top 1-day slow SQL locations and Top 7-day slow SQL locations for a certain period.​
  • View slow log details: In the Slow SQL List section, filter slow SQL templates as needed and view detailed information of slow SQL within the templates. Specific parameters are shown in the table below.​
tip​
Before viewing slow SQL details on the slow SQL list pane, you need to click the bar graph of a certain point in time in the slow log development trend graph.​
  • ​
    Target​
    Description​
    Enable/Disable shard compatibility​
    • After enabling Shard compatible, in the sharding scenario, SQL templates with the same logical database and table names will be aggregated together, and the aggregated SQL template will be displayed.​
    • After disabling Shard compatible, all SQL templates are displayed in the sharding scenario.​
    tip​
    In general, the number of SQL templates after shard compatibility is enabled is less than the number of SQL templates after shard compatibility is disabled.​
    Filter slow SQL​
    Click Advanced filtering. In the expanded filter area, configure the following parameters as needed, and then click Query.​
    • Aggregation method: Select whether to check Aggregation ignores execution User, Aggregate ignore IP source, or Aggregate ignore DB as needed. You can select multiple options at the same time.​
    By default, execution User and IP source are ignored for aggregation. To view by User or IP dimension, deselect the corresponding aggregation method options here.​
    • Database: Select the target database from the drop-down list. Multiple selections are supported.​
    • User: Select the target user from the drop-down list. Multiple selections are supported.​
    • IP: Select the IP from the drop-down list. Multiple selections are supported.​
    • Keywords: Enter the keywords to be queried in the input box, such as select, from, and drop.​
    • Execution time range: Set the execution time range in the input box. The minimum time range must be less than or equal to the maximum time range.​
    View slow SQL list​
    On the Slow SQL list pane, you can perform the following operations:​
    • View the information of each SQL template, including the SQL template's Database name, Execution user, IP source, Execution times, Total time consumption(s), Maximum execution time(s), Average execution time(s), Maximum lock wait time(s), Average lock wait time(s), Maximum rows returned, Average rows returned, Maximum rows scaned, Average rows scanned, First appearance time, Last appearance time, and Table name. You can also click Advanced filtering to view the SQL template that meets the target.​
    tip​
    • The SQL template column can display up to 3 lines of SQL text.​
    • The Slow SQL list area displays slow logs from the past 10 minutes by default.​
    • Each SQL template aggregates all SQL commands that match the template.​
    • The database proxy is enabled by default for the RDS for MySQL instance. Therefore, the connection pool may be reused, that is, one connection is shared by multiple clients, which may cause the IP source to be inconsistent with the actual IP address and port.​
    • Total time consumption(s) refers to the total time consumption of all executions of SQL statements in the SQL template, in seconds.​
    • Maximum execution time(s) and Average execution time(s) refer to the maximum and average execution time of a single SQL statement in the SQL template, in seconds.​
    • View SQL index optimization suggestions:​
    1. Click SQL optimization in the Actions column of the target SQL template. In the Allow authorization dialog box, click Authorize.​
    • The SQL optimization suggestion function needs to sample and analyze the content of the database and table. Therefore, when you view the index optimization suggestion of SQL for the first time, you need to authorize DBW to read the database and table. If it is enabled, you do not need to perform this operation again.​
    • It takes approximately 10 to 20 seconds to view SQL optimization suggestions.​
    1. In the SQL optimization suggestions dialog box, view SQL optimization suggestions, including the executed SQL statement, Execution plan, and Optimization suggestions, including Index optimization and SQL rewrite.​
    tip​
    If the Automatic index creation function has been enabled in AutoOps, DBW automatically creates indexes for the current slow SQL based on the SQL optimization suggestions. For more information, refer to Automatic index creation management.​
    View slow SQL details​
    Click the target SQL template under the SQL template column. In the SQL details panel, you can view relevant parameter information under different tabs:​
    • Execution details: On the Execution details tab, you can perform the following operations:​
    • View the information of each SQL statement, including the SQL statement's Start time, SQL text, Database, Execution user, IP source, Execution time(s), Lock wait time(s), Rows scanned, and Rows returned. At the same time, you can click the copy icon to copy the SQL text, and click the filter icon after Execution user or IP source to filter User or IP.​
    tip​
    The database proxy is enabled by default for the RDS for MySQL instance. Therefore, the connection pool may be reused, that is, one connection is shared by multiple clients, which may cause the IP source to be inconsistent with the actual IP address and port.​
    • View SQL optimization suggestions:​
    1. Click SQL optimization in the Actions column of the target SQL text. In the Allow authorization dialog box, click Authorize.​
    • The index optimization suggestion function needs to sample and analyze the content of the database and table. Therefore, when you view the index optimization suggestion of SQL for the first time, you need to authorize DBW to read the database and table. If it is already enabled, you do not need to perform this operation again.​
    • It takes about 10 to 20 seconds to view SQL index optimization suggestions.​
    1. In the SQL optimization suggestions dialog box, view SQL optimization suggestions, including the executed SQL statement, Execution plan, and Optimization suggestions, including Index optimization and SQL rewrite.​
    • tip​
    • If the Automatic index creation function has been enabled in AutoOps, DBW automatically creates indexes for the current slow SQL based on the SQL optimization suggestions. For more information, refer to Automatic index creation management.​
    • Execution statistics: On the Execution statistics tab, you can view all SQL text information that meets the filtering criteria in the SQL template.​
    • Total time consumption ratio: The proportion of the total time consumption of the current SQL template to the total time consumption of all SQL lists within a certain period of time.​
    • Total lock wait time ratio: The ratio of the total lock wait time of the current SQL template to the total lock wait time of all SQL lists within a certain period of time.​
    • Percentage of total rows scanned: The ratio of the total number of scanned rows in the current SQL template to the total time consumption of all SQL lists within a certain period of time.​
    • Percentage of total rows returned: The ratio of the total number of returned rows in the current SQL template to the total number of returned rows in all SQL lists.​
    • SQL execution times: view the trend of slow SQL within the filtered time period.​
    • Execution profiling: Displays the execution status of SQL statements in each stage to help you analyze and locate problems.​
    • SQL analysis: on the SQL analysis tab, you can view the following information.​
    • SQL text: includes all SQL text information within the SQL template, click the copy icon to copy the SQL text.​
    • Execution plan: Includes select_type information interpretation, type information interpretation, and extra information interpretation.​
    • Optimization suggestions: Includes optimization suggestions for SQL statements. You can refer to these suggestions to optimize your SQL statements.​
    ​
Download a slow log​
tip​
  • Up to 1 million slow log entries can be downloaded in a single request.​
  • Slow log download tasks are retained for 1 day by default. Expired tasks will be automatically deleted.​
  • View and export the download file of slow log in the export history.​
  1. Log on to the DBW console.​
  1. On the top menu bar, switch the region.​
  1. On the left navigation bar, select Operation and maintenance management > Observation and diagnosis.​
  1. On the upper-left corner of the Observation and diagnosis page, click the icon to the right of the Instance name.​​icon, and select the target instance.​
  1. On the target instance page, click Log management.​
  1. On the Slow log details tab, select a node ID and a timeframe as needed.​
  1. In the Slow SQL list area, filter the target slow logs as needed, and then click the​​icon.​
  • ​​​
  • Select the range of slow logs to download as needed. Currently, Export slow log details and Export current page are supported. The specific configurations are as follows:​
  • Export slow log details​
  • The exported slow log details include slow SQL that can be executed directly.​
  • Click Export slow log details. In the Export slow log details dialog box, configure the following parameters.​
  • ​
    Parameter​
    Description​
    File format​
    Currently, only the CSV slow log format for downloads is supported. No selection is required.​
    Export range​
    Select the range of slow logs to download as needed. Currently, Custom, Past 2 hours, Past 12 hours, and Past 24 hours are supported.​
    Custom time period​
    Select the time range for log export.​
    tip​
    This parameter can be set when Export range is set to Custom.​
    ​
  • Export current page​
  • Click Export current page. In the Export slow logs of the current page dialog box, select the information included in the downloaded slow logs as needed.​
  • The current slow log download can include SQL template, Database name, Executing user, IP source, Execution times, Total time (s), Maximum execution time (s), Average running time (s), Maximum lock wait time (s), Average lock wait time (s), Maximum rows returned, Average rows returned, Maximum rows scaned, Average rows scanned, First appearance time, and Last appearance time, and Table name.​
  1. Click OK.​
  1. On the Slow log tab, click​​icon, and then click Export history.​
  1. In the Export History dialog box, select the target task whose Status is Generated, and click Download file in the Actions column.​
Related APIs​
​
API​
Description​
Call the DescribeSlowLogs API to query slow log information.​
​
​
Last updated: 2026.09.01 16:57:38