---
title: "The new cost-based join optimizer with reordering support for non-inner joins"
description: "ClickHouse's new cost-based join optimizer uses an exhaustive DPsub dynamic-programming enumerator over table-subset bitmasks."
url: "https://swe.quest/articles/the-new-cost-based-join-optimizer-with-reordering-support-for-non-inner-joins-60f6c88dd7c8b7a9"
canonical: "https://clickhouse.com/blog/the-new-cost-based-join-optimizer-with-reordering-support-for-non-inner-joins"
source: "ClickHouse"
published: "2026-10-28"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 17
tags: ["query-engines","algorithms","analytics","performance"]
---

# The new cost-based join optimizer with reordering support for non-inner joins

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-10-28, 17 min read, Deep dive. Original: [https://clickhouse.com/blog/the-new-cost-based-join-optimizer-with-reordering-support-for-non-inner-joins](https://clickhouse.com/blog/the-new-cost-based-join-optimizer-with-reordering-support-for-non-inner-joins)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- SQL join semantics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- query execution plans
- dynamic programming
- relational algebra

## Keywords

ClickHouse, DPsub, cost-based optimizer, conflict detector, TPC-H, SIGMOD 2013

## Related posts

- [How ClickHouse became fast at joins](https://swe.quest/articles/how-clickhouse-became-fast-at-joins-68de042e0ff6c22e.md): ClickHouse · 2026-06-03 · Hard · 15 min read · Query engines, Analytics & OLAP, Performance engineering, SQL
  ClickHouse became 26× faster on the join-heavy TPC-H SF100 workload between 22.4 and 26.4.
- [ClickHouse Release 25.1](https://swe.quest/articles/clickhouse-release-25-1-dbd3d08d261fe532.md): ClickHouse · 2025-02-07 · Medium · 15 min read · Query engines, Analytics & OLAP, Performance engineering, Concurrency
  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.
- [ClickHouse Release 25.9](https://swe.quest/articles/clickhouse-release-25-9-512577de2ea7d4de.md): ClickHouse · 2025-10-02 · Medium · 10 min read · Query engines, Analytics & OLAP, Performance engineering, Search, SQL
  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.
- [ClickHouse Release 26.7](https://swe.quest/articles/clickhouse-release-26-7-1ce7ef970afa5876.md): ClickHouse · 2026-08-06 · Medium · 30 min read · Query engines, Analytics & OLAP, Performance engineering, Vector search
  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.
- [ClickHouse Release 25.10](https://swe.quest/articles/clickhouse-release-25-10-a4195d25b3b54d91.md): ClickHouse · 2025-11-07 · Medium · 17 min read · Query engines, Analytics & OLAP, Performance engineering, Vector search, SQL
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
