Running queries

The Queries view lists the SQL queries running right now, with their user, elapsed time, memory and progress. Use it to find the query that is slowing everything down, then stop it.

Open the running queries

  1. Open Observability and click ClickHouse.
  2. Select Queries in the view toggle.

The view is part of ClickHouse activity, and without View Active Queries it is not in the toggle. It holds a ClickHouse table and, hidden until you unlock it, a PostgreSQL table.

What the tables show

Each table lists one row per query running at the moment it loads.

TableColumns
ClickHouseQuery ID, User, Database, Query Kind, IP Address, Port, Initial Port, Elapsed Time, Memory Usage, Progress, Query
PostgreSQLPID, Blocking PID, DB Username, Application Name, IP Address, Query Start Time, Status Change Time, Status, Query, Wait Event

Find the query that is slowing things down

  1. Sort the list by Elapsed Time or Memory Usage to bring the slowest or heaviest queries to the top.
  2. Search, or filter a column, to narrow the list.
  3. Click a row to open its details on the right. To read the full SQL, click the view button in the Query cell; the preview has a copy button for the whole statement.

Stop a running query

Stopping needs Stop Active Queries. Without it, the stop icon is hidden at the end of the rows.

  1. Click the stop icon at the end of the query's row.
  2. In Terminate Query, read "Are you sure you want to terminate this query?" and click Confirm.
  3. You see Query terminated successfully when the request is accepted. If it fails, you see Failed to terminate query, with the reason.

Stopping takes a moment, so the query can stay in the list until you refresh.

Open a running query in the Editor

If you can use the Editor, the details panel shows Open in Editor; it opens the query's SQL in a console. The console is named Running Query PID {pid} for a PostgreSQL query and Running Query {first 8 characters} for a ClickHouse query, taken from the query id. If the query runs from one of your open consoles, the Editor focuses that console instead. See Query Management for how consoles work.

Unlock the PostgreSQL view

The PostgreSQL table is hidden by default. To unlock it:

  1. Select Queries in the view toggle.
  2. Click Queries ten times in a row. From the fifth click, a countdown message shows the taps left, from 5 more taps to unlock PostgreSQL down to 1 more tap to unlock PostgreSQL.
  3. After ten clicks you see PostgreSQL view unlocked, and the PostgreSQL view appears in the toggle.

Limits and edge cases

Questions, answered

I stopped a query, but it is still in the list. Why?

Stopping takes a moment, and the table does not update on a timer. Click Refresh data after a short wait.

Why is there no stop icon on a row?

Stopping needs Stop Active Queries. Without it, the icon is hidden. Ask an administrator to add it to your role; see the Permission reference.

How do I show the PostgreSQL table?

The PostgreSQL table is hidden until you unlock it. Select Queries and click it ten times in a row; from the fifth click a countdown shows the taps left. The unlock stays in this browser.

Where can I see queries that have finished?

Click Query history in the toolbar; it opens the query log in Query Management. The button appears when you hold View Query Management.

Where can I read the full SQL of a running query?

Click the view button in the Query cell of the row. The preview shows the whole statement, and its copy button copies it.

Can I open a running query in the Editor?

Yes, when you can use the Editor. Click the row to open its details, then use Open in Editor; the console is named Running Query PID {pid} for PostgreSQL and Running Query {first 8 characters} for ClickHouse.

Why is the Query ID column missing?

The Query ID column is hidden by default. Use View settings in the table toolbar to show it. Your column layout is kept in this browser.

Does search cover every running query?

The table loads up to 10,000 rows when it opens. Search, sorting and column filters then run in your browser over the loaded rows.

Do the running queries update on their own?

No. Click the refresh button (tooltip Refresh data) for the latest list.