Active queries
AnalyticDB for PostgreSQL provides the Active Queries feature, which automatically collects and displays a list of active queries every 5 seconds. You can use it to cancel blocking queries or terminate their corresponding sessions.
Procedure
- Log on to the AnalyticDB for PostgreSQL console.
- In the upper-left corner of the console, select a region.
- Find the instance that you want to manage and click the instance ID.
-
In the left-side navigation pane, choose Diagnostics and Optimization > Query Analysis.
-
On the Active Queries page, view the current active queries for the instance.
NoteYou can also filter queries by criteria such as Username, Execution Duration, Database, or SQL keywords.
-
Cancel or terminate queries as needed.
-
Cancel Task (Recommended): If a query runs for too long or consumes excessive resources, you can cancel it. This action runs the pg_cancel_backend() function to gracefully cancel the query. If successful, the query stops, but the client connection remains active and can submit new queries.
-
Terminate: If a client connection is in a bad state or you want to end the entire session and release all its resources, you can use this option. This action runs the pg_terminate_backend() function to immediately terminate the specified backend process. The client connection associated with the process is forcibly disconnected.
Note-
You can apply the Cancel Task or Terminate operation to multiple queries at once.
-
The Cancel Task and Terminate operations are asynchronous. A query might temporarily remain in the list after you perform one of these actions. The query usually disappears after the next automatic refresh.
If a query remains in the list for a long time (for example, 3 minutes) after you perform the Cancel Task or Terminate operation, the action may have failed. In this case, you can Submit a ticket for further investigation.
-