When queries slow down, identifying the root cause quickly reduces downtime and user impact. PolarDB for PostgreSQL provides a slow SQL analysis feature that lets you:
Spot slow query trends before they impact users
Identify whether slowdowns stem from lock contention, I/O waits, or other causes
Diagnose specific SQL statements and get optimization suggestions
Apply SQL throttling to control runaway queries
View slow query logs
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 and review the sections below.
Slow Query Log Trends — Shows how slow query frequency changes over time. Click any point in the chart to see the statistics and details for that moment. To filter by node, select a node from the Node ID drop-down list.
NoteIf an SQL statement is truncated due to display length limits, hover over the statement to see the full text.
NoteTimestamps in slow query logs reflect the time zone in effect when each SQL statement ran. The time zone is resolved in the following order: session level > database level > system level. If a time zone is specified for the database, the execution time is recorded based on the database time zone; otherwise, it is recorded based on the system time zone. If a statement modifies the session-level time zone, the logged execution time may differ from the actual execution time.
Event Distribution — Query slow query log events within the selected time range. Click an event to view its details.
Slow Query Log Statistics — Find the SQL template that you want to manage and click Details in the Actions column. In the Slow Log Sample dialog box, view the slow query log sample of the SQL template.
Slow Query Log Details — Lists individual SQL statements. For each statement, click Optimize in the Actions column to run SQL diagnostics and get optimization suggestions, or click Throttling to apply SQL throttling.
NoteThe end time must be later than the start time. The time range cannot exceed 24 hours, and you can query slow query logs from the previous month only.
To download slow query logs, click
.To debug an API call with the current query parameters, click
to open the OpenAPI console with the parameters pre-filled.
API reference
Operation | Description |
Queries the details of slow logs for a cluster | |
Queries whether SQL data collector is enabled for a cluster | |
Enables or disables SQL data collector for a cluster |