Canonical: https://weaveos.com/reference/clickhouse/investigate-slow-queries

1. [Software capabilities](https://weaveos.com/reference)
2. /[ClickHouse](https://weaveos.com/reference/clickhouse)
3. /Investigate slow ClickHouse queries

[![](https://weaveos.com/reference/logos/clickhouse.svg)ClickHouse](https://weaveos.com/reference/clickhouse)

# Investigate slow ClickHouse queries

ClickHouse's system.query\_log and Cloud Query Insights both expose query performance. Query the log when you need exact rows or SQL, or use Query Insights for grouped latency, error, and recent-query views.

Documentation reviewed November 27, 2026 · 2 methods with sources

## Ways to do it

1. [1CLI: clickhouse-client query system.query\_log](https://weaveos.com/reference/clickhouse/investigate-slow-queries#method-1)
2. [2Interface: Cloud Monitoring → Query insights](https://weaveos.com/reference/clickhouse/investigate-slow-queries#method-2)

CLI

### clickhouse-client query system.query\_log

Run a read-only query against the query log and order completed initial queries by duration to find recent slow work.

[Read source: ClickHouse system.query\_log](https://clickhouse.com/docs/reference/system-tables/query_log)

- Requirements

  A ClickHouse client, a secure service endpoint, database credentials, SELECT access to system.query\_log, and the REMOTE grant for clusterAllReplicas. In ClickHouse Cloud use the default cluster. Use --ask-password for an interactive password prompt.

- Limitations

  Cloud query-log rows are local to each node, so a direct system.query\_log query can miss other replicas. The log also flushes on its configured interval and does not store query results.

Example shell

Copy

```
clickhouse-client --host "$CLICKHOUSE_HOST" --secure --ask-password --user "$CLICKHOUSE_USER" --query "SELECT query_id, query_duration_ms, read_rows, query FROM clusterAllReplicas('default', system.query_log) WHERE type = 'QueryFinish' AND is_initial_query = 1 AND event_time >= now() - INTERVAL 1 HOUR ORDER BY query_duration_ms DESC LIMIT 20 FORMAT JSONEachRow"
```

Interface

### Cloud Monitoring → Query insights

Select a ClickHouse Cloud service, open Monitoring, then Query insights to view latency percentiles, query volume, errors, filters, and query drill-down details.

[Read source: ClickHouse Cloud Query insights](https://clickhouse.com/docs/products/cloud/features/sql-console-features/query-insights)

- Requirements

  A ClickHouse Cloud account with access to the service and a role that can view its monitoring data.

- Limitations

  The recent-query table groups entries by normalized query hash and user over the selected time window, so it is an aggregate view rather than a raw per-row query log export.

## More from ClickHouse

[View all 1 ClickHouse tasks](https://weaveos.com/reference/clickhouse)
