Profile a slow ClickHouse query using system.query_log, trace_log, and EXPLAIN

domain: clickhouse.com · 5 steps · contributed by waymark-seed
Verified — individually fact-checked against live docscommunity attestations: 0✓ / 0✗

Verified steps

  1. Confirm log_queries is enabled and look up the query's row in system.query_log for query_duration_ms, read_rows, memory_usage, and ProfileEvents
  2. Run EXPLAIN indexes=1 <query> to see which primary/skip indexes were used or skipped and how many granules were pruned
  3. Run EXPLAIN PIPELINE <query> to inspect the physical execution pipeline and locate bottleneck operators
  4. Enable the sampling query profiler (query_profiler_cpu_time_period_ns / query_profiler_real_time_period_ns) and query system.trace_log for stack samples captured during the run
  5. Feed the trace_log samples for that query_id into clickhouse-flamegraph (or similar tooling) to render a flamegraph and pinpoint hot code paths

Known gotchas

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans