Updated on 2025-10-22 GMT+08:00

Viewing ClickHouse Slow Query Statements

There are two tabs on the Slow Query Management page: Ongoing Slow Queries and Completed Queries. By default, SQL statements whose latency exceeds 500 milliseconds in the cluster are displayed. You can manually determine whether to terminate an ongoing SQL statement.

Querying Ongoing Slow SQL Statements

  1. Log in to the CloudTable console.
  2. Click the name of the target cluster to access its details page. In the navigation pane, choose Slow Query Management > Ongoing Slow Queries.
  3. Use filter criteria such as the latency, time range, user, remote IP, and SQL statement to quickly find out or kill the desired slow queries.

    Table 1 Ongoing slow query parameters

    Parameter

    Description

    Query ID

    ID generated internally

    Start Time

    Time when the execution of a slow query SQL statement starts

    End Time

    Time when the execution of a slow query SQL statement ends

    Database

    Database where the data table is located

    SQL Statement

    Ongoing SQL statement

    Latency (ms)

    Execution time of a slow query SQL statement. Unit: ms

    User

    User who executes the query

    Remote IP

    IP address of the client that submits the query

    Status

    Status of the slow query SQL statement: RUNNING

    Operation

    You can click Kill Query as required.

    Table 2 Slow query filter conditions

    Condition

    Description

    Slow query duration

    Enter a filter value as required. The value cannot be less than 10 ms. You can also select 15 minutes, 30 minutes, or 1 hour on the console.

    Slow query running date

    Enter a date and time range for filtering as required.

    Query by SQL

    Filters slow queries based on SQL statements.

    Query by user

    Filters the slow queries based on users who execute the SQL statements.

    Fuzzy search based on part of a username is supported.

    Query by remote IP address

    Filters the slow queries based on the IP address of the client that submits slow query SQL statements.

Querying Completed Slow SQL Statements

  1. Log in to the CloudTable console.
  2. Click the name of the target cluster to access its details page. In the navigation pane, choose Slow Query Management > Completed Queries.
  3. Use filter criteria such as the latency, time range, status, user, remote IP, and SQL statement to quickly find out the desired slow queries.

    Table 3 Completed slow query parameters

    Parameter

    Description

    Query ID

    ID of each SQL command

    Start Time

    Time when the SQL statement starts to be executed

    End Time

    Time when the SQL statement execution ends

    Database

    Queried database

    SQL Statement

    Completed SQL statement

    Latency (ms)

    SQL execution duration

    Status

    SQL status, including FINISHED and CANCELLED.

    User

    User who submitted the SQL statement

    Remote IP

    Address of the client used by the user who submitted the SQL statement

Slow SQL Query Statuses

The slow SQL query statuses include FINISHED, RUNNING, or CANCELLED. When the status is RUNNING, Kill Query is displayed in the Operation column.

Table 4 Status description

Status

Description

FINISHED

The SQL statement has been executed.

RUNNING

The SQL statement is running. You can determine whether to stop it.

CANCELLED

The execution of the SQL statement is canceled.