1. Read filter column first
PREWHERE reads only the host column first to find surviving rows.
PREWHERE host = 'web-1'Typorithm · hard
Step 1 of 8 · intro card
Indexing & Partitioning
PREWHERE reads only its filter columns first to find surviving rows, then reads the remaining columns just for those rows — saving I/O in the column store.
In a column store, reading fewer columns for fewer rows is the main lever for speed, and PREWHERE exploits exactly that.
PREWHERE first reads only the columns in its condition, identifies which rows pass, and then reads the other selected and WHERE columns only for those surviving rows.
ClickHouse can move WHERE conditions into PREWHERE automatically, but writing PREWHERE explicitly lets you put the cheapest, most selective filter first.
PREWHERE reads filter columns first.
Other columns read only for survivors.
Best for cheap, selective filters.
SELECT
request_id,
latency
FROM requests
PREWHERE host = 'web-1'
WHERE latency > 100;Connect each part of the code to the concept before you type.
PREWHERE reads only the host column first to find surviving rows.
PREWHERE host = 'web-1'WHERE applies to remaining columns only for rows that survived PREWHERE.
WHERE latency > 100Projected columns are read last, only for the surviving rows.
request_id,
latencyRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.