All Products
Search
Document Center

AnalyticDB:Active queries

Last Updated:Sep 23, 2023

AnalyticDB for PostgreSQL collects and refreshes the list of active query tasks every 5 seconds. You can cancel blocked query tasks or terminate relevant sessions based on your business requirements.

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 > Query Analysis.
  5. On the Active Queries tab, view the active query tasks of the instance.

    Note

    You can filter the query tasks by username, execution duration, database, or SQL statement.

  6. Perform the Cancel Task or Terminate operation based on your business requirements.

    • Cancel Task (recommended): If a query task runs for an extended period of time or consumes excess resources, you can cancel the task. The system executes the pg_cancel_backend() operation to cancel the task. After the query task is canceled, the relevant client remains connected to the service, and you can continue to submit other query tasks.

    • Terminate: If the network connection between the client of a query task and the service is unstable, or if you want to end the session of a query task and release relevant resources, you can terminate the task. The system executes the pg_terminate_backend() operation to terminate the task. After the task is terminated, the relevant client is disconnected from the service.

    Note
    • You can select multiple query tasks and perform the Cancel Task or Terminate operation on the tasks at a time.

    • The Cancel Task and Terminate operations are asynchronous. After you perform one of the preceding operations on a query task, the task may be temporarily displayed in the list. In most cases, the query task is no longer displayed after the next automatic refresh is complete.

      If a query task remains in the list for 3 minutes or longer after you perform the Cancel Task or Terminate operation, the query task may fail to be canceled or terminated. To resolve this issue, Submit a ticket.