Skip to main content

Useful queries for troubleshooting

In no particular order, here are some handy queries for troubleshooting ClickHouse and figuring out what is happening. We also have a great blog with some essential queries for monitoring ClickHouse.

View which settings have been changed from the default

Get the size of all your tables

The response looks like:

Row count and average day size of your table

Compression columns percentage as well as the size of primary index in memory

You can see how compressed your data is by column. This query also returns the size of your primary indexes in memory - useful to know because primary indexes must fit in memory.

Number of queries sent by client in the last 10 minutes

Feel free to increase or decrease the time interval in the toIntervalMinute(10) function:

Number of parts in each partition

Finding long running queries

This can help find queries that are stuck:
Using the query id of the worst running query, we can get a stack trace that can help when debugging.

View the most recent errors

The response looks like:

Top 10 queries that are using the most CPU and memory

A single query can be logged as multiple rows with different query_id values — distributed secondary queries and internal view steps have is_initial_query = 0. Filter on is_initial_query = 1 (or query_id = initial_query_id) to see queries as they were submitted, and note that the internal query_id values ClickHouse assigns may include a label such as queryView.... See the query_log reference for details.

How much disk space are my projection using

Show disk storage, number of parts, number of rows in system.parts and marks across databases

List details of recently written new parts

The details include when they got created, how large they are, how many rows, and more:

Cluster-wide monitoring queries

The following queries are useful for monitoring ClickHouse clusters. They use clusterAllReplicas() to aggregate data across all nodes.
These queries assume your cluster is named default. If your cluster has a different name, replace 'default' and default with your cluster’s actual name.

Average new parts created per minute and second (last hour)

Replace 'your_table' with the actual table name you want to monitor.

CPU and memory intensive queries (cluster-wide)

Merges in progress with ETA

This query shows currently executing merges on the cluster with estimated time to completion:

Most common queries by normalized hash

Find the most frequently executed queries (useful for identifying which queries to optimize):

Error counts by event type and date

Analyze part creation errors across the cluster:

Number of tables by node

Check table distribution across cluster nodes:

Check for async insert operations

Monitor async insert activity:

Parts and merges analysis

Currently active parts by table

See the number of active parts per table across the cluster:

Partitions with too many parts

Find partitions that may have too many parts (which can impact query performance):

Detached parts

Check for detached parts that might need investigation:

System information queries

Cluster-wide memory usage by node

Monitor memory consumption across nodes:

Running queries on the cluster

Check what queries are currently executing:

Modified settings from defaults

See which settings have been changed from defaults:

Replication queue status

For replicated tables, check the replication queue:
Last modified on June 23, 2026