The slow SQL analysis feature in PolarDB for PostgreSQL (Compatible with Oracle) helps you identify and resolve query performance issues without leaving the console. Use it to visualize slow query trends, examine event distributions, drill into individual SQL statements, and take corrective action through diagnostic optimization or SQL throttling.
Slow SQL analysis views
The Slow Log Analysis tab provides four views. Each view serves a distinct purpose:
| View | Description |
|---|---|
| Slow Query Log Trends | A time-series chart showing how slow query frequency changes over the selected time range. Use it to spot performance spikes and correlate them with deployment or traffic events. |
| Event Distribution | A breakdown of slow query log events within the selected time range. Click an event to see its details. |
| Slow Query Log Statistics | Slow queries grouped by SQL template. Use this view to identify recurring patterns and templates responsible for the most performance overhead. |
| Slow Query Log Details | Individual SQL statements with options to run diagnostic optimization or apply throttling. |
Analyze slow queries in the console
Log on to the PolarDB console. In the left-side navigation pane, click Clusters. In the upper-left corner, select the region of the cluster. In the cluster list, find the cluster and click its ID to go to the Basic Information page.
In the left-side navigation pane, choose Diagnostics and Optimization > Slow SQL.
On the Slow Log Analysis tab, set a time range to filter data.
The end time must be later than the start time, and the interval cannot exceed 24 hours. You can query slow query logs from the previous month.
Use the four views to investigate slow queries:
Slow Query Log Trends
The trend chart shows slow query frequency over your selected time range.
Click any point in the chart to see statistics and log details at that moment.
From the Node ID drop-down list, select a node to view the number of slow queries on that node.
If an SQL statement is truncated due to display limits, hover over it to see the full text.
Click the download icon to save the slow query logs to your computer.
Click the OpenAPI icon to send the current parameters to the OpenAPI console for API debugging.
Event Distribution
This section lists slow query log events within the selected time range. Click an event to see its details.
Slow Query Log Statistics
This tab groups slow queries by SQL template. To inspect log samples for a template, find the template and click Details in the Actions column. The Slow Log Sample dialog box shows representative log entries for that template.
Slow Query Log Details
This tab lists individual SQL statements. To take action on a statement, find it and click one of the following in the Actions column:
Action What it does Optimize Runs SQL diagnostic analysis on the statement and returns suggestions for improving performance. Throttling Applies SQL throttling to limit the rate at which the statement executes.
FAQ
Why does the execution completion time in slow query logs differ from the actual time?
This happens when an executed SQL statement modifies the time zone recorded in the slow query log. Completion time is determined by the time zone resolved in the following order: session level, then database level, then system level. If the database has a configured time zone, that time zone is used. Otherwise, the system time zone applies. When a statement changes the time zone at the session level, the recorded time may not convert correctly, causing the discrepancy.
API reference
| Operation | Description |
|---|---|
| DescribeSlowLogRecords | Queries the details of slow logs for a cluster. |
| DescribeDBClusterAuditLogCollector | Queries whether SQL data collector is enabled for a cluster. |
| ModifyDBClusterAuditLogCollector | Enables or disables SQL data collector for a cluster. |