ClickHouse

Query Profiler CPU Bottleneck

warning
Resource ContentionUpdated Jan 21, 2026

CPU-intensive query operations (complex aggregations, string parsing, decompression) saturate CPU resources, causing query queuing and increased latency. This is identifiable through high UserTimeMicroseconds in query profiles.

How to detect:

Monitor CPU time per query via ProfileEvents['UserTimeMicroseconds'] and ProfileEvents['SystemTimeMicroseconds'] in system.query_log. Track system-wide CPU wait. Alert when queries consistently consume >10s CPU time or when CPU wait increases.

Recommended action:

Use EXPLAIN PIPELINE to identify CPU-intensive pipeline stages. Enable query profiling and analyze flamegraphs via system.trace_log to find hot functions. Optimize with pre-aggregated materialized views, simpler expressions, or better codecs. Scale CPU resources if workload is inherently CPU-bound.