The new cost-based join optimizer with reordering support for non-inner joins
ClickHouse's new cost-based join optimizer uses an exhaustive DPsub dynamic-programming enumerator over table-subset bitmasks. It finds the cheapest plan under the existing cost model for up to 10 tables by default, or 12 when the limit is raised, and is slated to be enabled by default in release 26.11. A conflict detector based on the SIGMOD 2013 core-search-space paper lets the optimizer also reorder LEFT/RIGHT/FULL outer, SEMI and ANTI joins, which previously acted as optimization barriers. The detector uses comm/assoc/l-asscom/r-asscom rules and null-rejection checks to admit only result-preserving reorderings, and both its correctness and completeness are proven. In one example, pushing a semi join below an inner join shrank the largest intermediate result about 496×, and testing across 90,000+ join trees found no invalid or missing plans.
Related posts
- How ClickHouse became fast at joins
ClickHouse hardMaster
ClickHouse became 26× faster on the join-heavy TPC-H SF100 workload between 22.4 and 26.4. In the first year (4.4×) parallel hash join became the default, build and probe phases were optimized and two-table reordering was added. In the second year (another 6× with default settings) four changes landed: decorrelation of correlated subqueries, lazy column replication, runtime filters and statistics-based join reordering. Lazy replication represents repeated join outputs as dictionary indexes instead of copying wide strings (1.9× faster in a self-join benchmark). Runtime bloom/min-max filters built from build-side keys are applied as PREWHERE on the probe side (2.1× faster, peak memory cut from 1.24 GiB to 185 MiB).
- ClickHouse Release 25.1
ClickHouse mediumAdept
ClickHouse 25.1 speeds up the default parallel hash join by building N two-level hash tables whose 256 buckets are filled by threads in a non-overlapping way, then merging them in constant time into one shared table. The probe phase can then read that table concurrently without splitting input blocks, and it uses a single hash function where the old design used two. Benchmarks on a 32-vCPU m6i.8xlarge show roughly 37% faster joins on a synthetic query and 32% faster on a TPC-H SF100 lineitem/orders join. The release also adds the add_minmax_index_for_numeric_columns setting, which creates MinMax skip indexes on every numeric column, and it improves Merge tables and adds auto-increment support.
- 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 26.7
ClickHouse mediumAdept
ClickHouse 26.7 ships 61 features, 112 performance optimizations and 329 bug fixes, led by a fused ordered-aggregation pipeline that pushes LIMIT into in-order GROUP BY. On TPC-H SF100 it made a Top-N order-summary query 313× faster with 592× less memory by stopping reads once N groups complete. JOIN gains include runtime filters from the build side that skip probe-side granules via primary-key and skip-index analysis (6.2× faster on a selective TPC-H join), compact 8-byte row references in hash tables (median 12% faster, 15% less memory), and a new dpsub join-ordering algorithm that can chain with greedy as a fallback. Vector search also improves through QBit additions such as Int8 support, strided storage, randomized Hadamard rotations and quantization codecs, alongside phrase search, EXPLAIN ANALYZE and unified URL access.
- ClickHouse Release 25.10
ClickHouse mediumAdept
ClickHouse 25.10 focuses on JOIN performance, adding lazy columns replication (an index column pointing at the original data instead of copying duplicated values), runtime Bloom filters built from the right-side join keys and applied as PREWHERE on the left side for parallel hash joins, push-down of OR conditions that reference both join sides, and automatic column statistics via auto_statistics_types to feed join reordering. Benchmarks on an m6i.8xlarge show a self-join over 20× faster with lazy replication, a TPC-H join 2.1× faster with ~7× less memory using runtime filters, and 24× faster with 60× less memory from disjunction push-down. The release also introduces the QBit bit-sliced vector type for query-time precision tuning, plus SQL additions such as general support for the <=> operator.