Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 4 min read Deep dive mediumAdept

Streaming secondary indices: incremental, demand-driven index evaluation

ClickHouse 25.9 introduces streaming secondary indices, which check skip-index entries (minmax, set, bloom filter, vector, text) incrementally as each table granule is about to be read, instead of scanning the whole index before query execution. Interleaving index checks with data reads removes the startup delay and lets queries with LIMIT stop both index scanning and granule reads as soon as the result is complete. On a one-billion-row table with a 2.2 GiB bloom filter index, a LIMIT 1 needle lookup dropped from ~10.2s to ~2.5s and peak memory halved. The feature is controlled by the use_skip_indexes_on_data_read setting.

Assumes: ClickHouse MergeTree granulesdata skipping indexesbloom filters

Related posts

  • How ClickHouse makes Top-N queries faster with granule-level data skipping

    ClickHouse mediumAdept

    ClickHouse can now use minmax data-skipping indexes to prune whole granules for ORDER BY … LIMIT N queries before reading any rows. Without predicates, it preselects only the granules with the smallest min (or largest max) values. With predicates, it keeps a dynamic N-th-value threshold during streaming execution and skips granules whose min/max cannot improve the result. On the 100M-row hits dataset, enabling use_skip_indexes_for_top_k and use_top_k_dynamic_filtering made Top-N queries 5–10× faster and cut data read by 10–100×, and a 50B-row production table answered in under 0.2 s. The pruning composes with streaming Top-N, read-in-order and lazy reading, and it pays off most on large tables, cold caches and object storage.

  • ClickHouse Release 25.9

    ClickHouse mediumAdept

    ClickHouse 25.9 adds automatic global join reordering, which uses a greedy algorithm plus row-count estimates or manually created column statistics to pick build/probe order across many tables. On a six-table TPC-H query at scale factor 100 it cut runtime from over an hour to 2.7 seconds (~1,450×) with ~25× less memory. Secondary indices are now checked granule by granule while data is read, so LIMIT queries stop early; one LIMIT 1 query ran over 4× faster. Other changes include an experimental streaming-friendly text index replacing the FST design, Iceberg write and metadata improvements, arrayExcept, argument-less boolean settings, and S3 storage class selection.

  • ClickHouse Release 25.12

    ClickHouse hardMaster

    ClickHouse 25.12 ships 26 features, 31 performance optimizations and 129 bug fixes, led by three query-engine speedups. Top-N queries (ORDER BY … LIMIT N) now compare the running threshold against granule-level min/max skip-index metadata to skip granules before reading, cutting data read by one to two orders of magnitude and speeding queries 5–10×. Lazy materialization moved from row-by-row column fetches to a batched join-style step (JoinLazyColumnsStep), making a LIMIT 100,000 query about 75× faster (38.7s to 0.51s), and its default limit was raised from 10 to 10,000. An experimental DPsize dynamic-programming join reordering algorithm for INNER JOINs explores more join orders than the greedy approach and produces a better plan on a TPC-H eight-table query.

  • Index-based pruning in ClickHouse

    ClickHouse mediumAdept

    ClickHouse offers three index-based ways to skip data: the sparse primary index (one entry per 8,192-row granule), lightweight projections that store only a sort key plus a _part_offset pointer into the base table, and skip indexes such as minmax that keep per-granule min/max values. On a 243-million-row UK property sales table, a filter on the leading primary-key column read 1.69 million rows in 15 ms. Filtering only on the second key column fell back to generic exclusion search, scanned 138 million rows and ran 50x slower. Lightweight projections handle filters on non-key columns without duplicating full rows, while minmax indexes cost even less storage but only prune well when the column correlates with the primary key.

  • ClickHouse projections now behave like true secondary indexes

    ClickHouse mediumAdept

    ClickHouse lightweight projections, which store only a sorting key plus a _part_offset pointer into the base table, now act as true secondary indexes with granule-level pruning instead of only pruning whole parts. Several such projections can combine with each other and with the base table's primary index to narrow the granules a query reads. On the UK price paid dataset, a query filtering on date and town dropped from a 30.7M-row full scan in 0.077 s to about 16k rows in 0.010 s, and EXPLAIN shows both projection indexes pruning granules in turn. Two new settings gate when projection indexes are used, and 26.1 adds a compact `PROJECTION ... INDEX col TYPE basic` syntax.

The quest for software engineering knowledge.

Look:
Layout: