⚑ Query Execution Pipeline

From SQL Text to Columnar Result β€” How ClickHouse Processes Every Query

πŸ”„ The Pipeline at a Glance

Every SELECT passes through these stages. Click a stage to learn more.

πŸ“
Parse
β†’
πŸ”
Analyze
β†’
πŸ“‹
Plan
β†’
βš™οΈ
Execute
β†’
πŸ“Š
Output

Click a stage above to see what happens inside.

πŸ“ Parsing: SQL β†’ Abstract Syntax Tree

ClickHouse uses a hand-written recursive descent parser (not yacc/bison). Type or pick a query to see its AST.

SELECT url, count() FROM hits WHERE date = '2024-03-01' GROUP BY url ORDER BY count() DESC LIMIT 10
Click "Parse to AST" to visualize the query tree

πŸ“‹ Query Plan: The Processor DAG

ClickHouse builds a DAG of processors β€” each transforms data chunks. This replaces the old BlockInputStream model since v21.6+.

Source (ReadFromMergeTree) Transform (Filter / Expression) Aggregate (GroupBy) Sort / Limit Output