Query Management

Query Management is the history of every SQL query run on your data. Use it to find which queries ran, which failed and which cost the most, then copy the ones you want to work on into the Editor.

Find a query in the log

  1. Open Observability > Query Management.
  2. Set Period in the toolbar. The default is Last 7d.
  3. Search, or filter a column, for example User or Log Name. To clear a column filter, click Reset in that filter.
  4. Click a row to open its details on the right. Click the same row again to close them.
  5. To reuse the SQL, copy it from the row's Query cell or from the Query section of its details, then paste it into a console in the Editor.
  6. To reload the list, click the refresh button in the toolbar. Its tooltip reads Refresh data.
  7. To look for patterns, select Repeated, Failed or High Maintenance in the toggle at the top of the tab.
  8. To export, pick CSV, Excel, JSON or TSV in the export control in the toolbar, then click the download icon next to it. See Periods, filters and exports.

Live ClickHouse sits at the top right of the tab and opens the Queries view of ClickHouse activity; it appears when you hold View Active Queries. From there, the Query history button brings you back to this tab, and it needs View Query Management.

Read a row's details

Click a row to open its details on the right; the open row stays highlighted. Click the same row again to close the panel.

A row opens only when it carries something to show: an error or an exception, or values in fields that are shown only in the details. Rows without any of those do not open.

Repeated, Failed and High Maintenance

The toggle at the top of the tab switches between four views. Each view lists its own columns and has its own default sort.

ViewWhat it listsSorted by default
Query ManagementEvery run in the query log, with its query, user, duration, memory and result.Query Start Time, newest first
RepeatedQueries that ran more than once, with Occurrence Count, Users, Tables, Avg Duration, Max Duration, Avg Memory, First Seen and Last Seen.Occurrence Count, highest first
FailedQueries with at least one error, with Error Count, Users, Tables, Avg Duration, Last Error, First Seen and Last Seen.Error Count, highest first
High MaintenanceEvery query with its total cost, including Total Duration, Total Memory and Total Read, with their averages.Total Duration, highest first

Repeated, Failed and High Maintenance select queries by Last Seen, the last time each one ran. Their counts and totals cover every run the log holds, not only the runs in the period you chose. Last Error shows the latest error message, without its stack trace.

A view with nothing to show reads No repeated queries found, No failed queries found or No high maintenance queries found. The export on these three views needs only View Query Management, and the file is named repeated_queries, failed_queries or high_maintenance_queries.

Settings and defaults

SettingWhat it doesDefault
PeriodSets the time range: Today, Last 7d, Last 30d or Custom.Last 7d
Rows per pageShows 50, 100 or 500 rows on each page.50
Tip

To see only the queries people ran, filter Log Name to User Query Log. The log also holds System Query Log rows for the platform's own queries, and System Query DDL Log rows for table changes.

Permissions

Permissions are granted through roles. See Roles and permissions and Permission reference.

Limits and edge cases

Questions, answered

Why do I see queries I never ran?

The log holds every query run on the ClickHouse database, including the platform's own queries and table changes. To see only the queries users ran, filter Log Name to User Query Log.

How do I find out why a query failed?

Open the Failed view to see queries with at least one error. The Last Error column shows the latest message. In Query Management, click the failed run and read its Exception section in the details panel.

Can I rerun a query from the log?

Not from the log itself. Click the row, copy the SQL from the Query section, and paste it into a console in the Editor. To open a query that is running now, use Open in Editor in its details on ClickHouse activity.

What counts as High Maintenance?

Every query in the log, grouped by its text. There is no threshold. The view sorts them by Total Duration, the sum of all their runs. Check Total Memory and Total Read as well.

Why is the count higher than the runs in my period?

The count covers every run the log holds. The Period selects queries by Last Seen, the time each one last ran. A query whose last run falls in the period shows all of its runs, including the earlier ones.

Why is the export button missing on the query log?

Exporting the Query Management view needs Export Audit Log, which the Audit Log Manager preset includes. The Repeated, Failed and High Maintenance views always show the export button, and they need only View Query Management.

Can I see who ran a query?

Yes. The User column shows the database user that ran each query. In Repeated, Failed and High Maintenance, the Users column lists everyone who ran the query.

How do I see queries that are running right now?

Click Live ClickHouse at the top right of the Query Management tab, or open ClickHouse > Queries. You need View Active Queries. To stop a running query, you need Stop Active Queries. See ClickHouse activity.

Why does clicking a query log row not open its details?

A row opens only when it carries something to show: an error or an exception, or values in fields that are shown only in the details, such as the tables the query read. Rows without any of those do not open. To close an open panel, click the row again.

Can I copy a query without opening its details?

Yes. The Query cell of each row has a copy control that puts the SQL on your clipboard, and a control that opens the full SQL in a preview titled Query. You can also open the row and use the copy control in its Query section. Paste the SQL into a console in the Editor to run it.

Does a Mind use this log?

Yes, some Minds do. When you ask a Lake Builder or Warehouse Builder Mind whether tables are still used, it reads the user and system query rows of the log, filtering by date, user or table name as needed, and it leaves out the system table-change rows. It refuses the check if you do not hold View Query Management.