You can analyze SQL queries executed within a specific time range, view execution plan details, and identify root causes of slow SQL queries in the AnalyticDB for PostgreSQL console.

Procedure

  1. Log on to the AnalyticDB for PostgreSQL console.
  2. In the upper-left corner of the console, select the region where the instance resides.
  3. Find the instance that you want to manage and click its ID.
  4. In the left-side navigation pane, choose Diagnosis and Optimization > Slow SQL Queries.
  5. Select a time range and click Search to view the search results.

View slow SQL queries

Slow SQL queries
No. Parameter or section Description
Database Name Enter the name of a database. If you want to search for slow SQL queries related to all databases in the instance, leave this parameter empty.
Select an execution duration Select an SQL execution duration from the drop-down list. Valid values:
  • Short (Duration < 10 Seconds)
  • Medium (10 Seconds <= Duration < 10 Minutes)
  • Long (Duration >= 10 Minutes)
  • Custom

    If you select Custom, you can specify Minimum Duration and Maximum Duration to customize the duration range. Unit: milliseconds or seconds.

Time range Select a time range to view slow SQL queries. By default, the last 1 hour is selected.
Note
  • You can search for slow SQL queries only within the last 14 days.
  • The end date must be later than the start date. Their interval must be less than seven days.
Search After you specify Database Name, Select an execution duration, and time range, click Search to view the search results.
Download SQL Click this button to download SQL query information displayed in the SQL query details section.
Line chart for SQL query quantity Allows you to view the change trend in the number of SQL queries executed within the specified time range.
SQL query details Allows you to view View execution plan, Query ID, Database Name, Start Time, Time spent on execution (ms), and SQL Statement of SQL queries.
Note Query ID and View execution plan are displayed only for the SQL queries that are executed for longer than 1 second.

View execution plan details

You can click the View Execution Plan icon in the View execution plan column to view execution plan details.

The following figure shows the execution plan details.

View execution plan details
No. Section Description
Basic query information Allows you to view Client IP, User Name, Database Name, Start Time, Time spent on execution (ms), Execution Status, and Returned Rows of the current SQL query.
SQL Statement and Execution Plan
  • SQL Statement: allows you to view the SQL statement information.
  • Execution Plan: allows you to view the execution plan tree that is displayed based on the PEV2 library. You can click the hidden nodes to view the execution plan details.
Execution Process Statistics Allows you to view the execution process statistics of an execution plan, including Compute Node, Execution Status, Execution Start Time, Execution End Time, Time spent on execution (ms), Processed Rows, and Memory Consumed (MB).