View slow queries

更新时间:
复制 MD 格式

In the AnalyticDB for PostgreSQL console, you can analyze SQL queries executed within a specific time range, view their execution plans, and identify the root causes of slow queries.

Procedure

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

Slow SQL queries page

查看慢查询
No. Item Description
Database Name Enter the name of the database that you want to query. If you leave this field empty, all databases in the instance are queried.
Select an execution duration Select an execution duration:
  • Short (Duration < 10 Seconds)
  • Medium (10 Seconds <= Duration < 10 Minutes)
  • Long (Duration >= 10 Minutes)
  • Custom

    You can specify a custom range by setting the Minimum Duration and Maximum Duration. The unit can be ms or s.

Query Time Range Select a time range. The default is the last hour.
Note
  • You can query information about slow queries that occurred within the last 14 days.
  • The end date must be later than the start date, and the time range cannot exceed seven days.
Search After you specify a Database Name, an Select an execution duration, and a Time Range, click Search to retrieve the query information.
Download SQL Queries Downloads the SQL statements listed in the SQL Query Details section.
SQL Query Count Chart Shows the number of SQL queries executed over the specified time range.
SQL Query Details Displays the details of each query, including a View Execution Plan link, Query ID, Database Name, Start Time, Execution Duration (ms), and the SQL.
Note The Query ID and View Execution Plan link appear only for queries that run for more than 1 second.

Execution plan

You can click the 查看执行计划图标 icon in the View Execution Plan column to view the execution plan details.

The figure below shows the execution plan details.

查看执行计划详情页
No. Section Description
Basic Query Information Displays basic information about the current SQL query, including Client IP, User Name, Database Name, Start Time, Execution Duration (ms), Execution Status, and Returned Rows.
SQL Statement and Execution Plan
  • SQL tab: Displays the full SQL statement.
  • Execution Plan tab: Displays the execution plan tree. The tree is rendered by using the PEV2 library. By default, nodes are collapsed. You can click a node to expand it and view detailed information.
Execution Process Statistics Displays execution statistics for the plan. You can view information for each Segment, including its Execution Status, Execution Start Time, Execution End Time, Execution Duration (ms), Processed Rows, and Memory Consumed (MB).