All Products
Search
Document Center

PolarDB:Slow query logs for PolarDB-X

Last Updated:Mar 30, 2026

When a query exceeds the performance threshold, the Slow Query Log feature logs it and surfaces it in the PolarDB-X console alongside CPU utilization trends. Use this feature to pinpoint queries causing performance spikes, group similar statements into SQL templates for pattern analysis, and get automated index recommendations from Database Autonomy Service (DAS).

Key concepts

PolarDB-X routes each application SQL statement through a distributed execution layer before sending sub-queries to the underlying storage nodes. Understanding the two query types is essential for effective diagnosis:

Query type Also called Description Optimization support
Compute Node (CN) slow query Logical SQL The original SQL statement your application sends to PolarDB-X. One CN query can generate multiple DN queries. Full support: DAS provides diagnostics and optimization suggestions.
Storage Node (DN) slow query Physical SQL Internal sub-queries that PolarDB-X sends to the underlying storage nodes. Not supported for direct optimization. Use DN queries for advanced troubleshooting of the distributed execution layer.

A query is classified as slow when its execution time exceeds 1 second.

Constraints and limits

  • Edition support: PolarDB-X Standard Edition only supports Storage Node (DN) slow queries.

  • Log retention: Slow query logs are retained for a maximum of 30 days and deleted automatically afterward.

  • Time range: Each query session is limited to a 24-hour window. You can query logs from the previous month.

  • DAS diagnostics latency: Optimization suggestions may take more than 20 seconds to generate, depending on query complexity, table data volume, and database load.

  • SQL display: If a SQL statement is truncated in the console due to length limits, hover over it to view the full content.

View slow query logs

  1. Log on to the PolarDB-X console.

  2. In the top navigation bar, select the region where the instance is deployed.

  3. On the Instances page, click the PolarDB-X 2.0 tab.

  4. Find the instance and click its name.

  5. In the navigation pane, choose Diagnostics And Optimization > Slow Query Logs. Select the Role and Node as needed.

  6. Set a time range. The end time must be later than the start time, and the interval cannot exceed 24 hours.

  7. Review the data across the following sections:

    • Slow Query Log Trends: Click the Compute Node (CN) or Data Node (DN) tab to switch between query types. Click any point in the trend chart to drill down into the statistics and details at that moment. Use the Node ID drop-down list to filter by a specific node.

    • Event Distribution: View slow query events within the selected time range. Click an event to see its details.

    • Slow Query Log Statistics: Aggregates similar statements into SQL templates, each showing execution count, average and maximum duration, and rows returned. From the Actions column for a given SQL template:

      • Click Details to view sample slow query log entries in the Slow Log Sample dialog box.

      • Click Optimize to open the SQL Diagnostic Optimization dialog box. DAS analyzes the query based on the complexity of SQL statements, the amount of data in the table, and the database load, then returns diagnostics results, optimization suggestions (such as local indexes and global secondary indexes), and estimated performance improvements. To apply the suggestions, click Copy and paste the optimized SQL statement into your database client or Data Management (DMS). To discard the suggestions, click Cancel.

      • Click Throttling to configure SQL throttling rules in the SQL Throttling dialog box. For more information, see SQL throttling.

    • Slow Query Log Details: Click Logical SQL Statements in the Actions column to view the CN and DN SQL statements for a specific log entry.

  8. To export the log data, click the download icon icon to download slow query logs to your computer. To open the API console for debugging, click OpenAPI icon to populate the current parameters into the OpenAPI console.