---
title: "ClickHouse Joins Under the Hood - Direct Join"
description: "ClickHouse's direct join is its fastest join algorithm. It applies when the right-hand table sits on storage that supports low-latency key-value lookups: the Join engine, EmbeddedRocksDB or a Dictionary."
url: "https://swe.quest/articles/clickhouse-joins-under-the-hood-direct-join-4c5bfc57b28f012b"
canonical: "https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4"
source: "ClickHouse"
published: "2023-06-07"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 15
tags: ["query-engines","analytics","performance","sql"]
---

# ClickHouse Joins Under the Hood - Direct Join

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2023-06-07, 15 min read, Deep dive. Original: [https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4](https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4)

## Summary

ClickHouse's direct join is its fastest join algorithm. It applies when the right-hand table sits on storage that supports low-latency key-value lookups: the Join engine, EmbeddedRocksDB or a Dictionary. The left table is streamed in parallel and each row is joined by looking it up directly in the in-memory structure, so there is no hash-table build phase (a FilledJoin step instead of FillRightFirst). Only LEFT ANY JOIN is supported, because dictionaries deduplicate on the key. A flat dictionary layout gives O(1) array-offset lookups at higher memory cost, and is 2-5x faster than a hashed layout. The worked examples use dictGet, EXPLAIN PLAN and timing comparisons against hash and parallel hash joins on a 100M-row table.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [SQL](https://swe.quest/tags/sql.md) (Languages)

## Prerequisites

- SQL joins ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- hash join basics
- ClickHouse table engines ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

ClickHouse, direct join, ClickHouse dictionaries, dictGet, EmbeddedRocksDB, LEFT ANY JOIN

## Related posts

- [Using Dictionaries to Accelerate Queries](https://swe.quest/articles/using-dictionaries-to-accelerate-queries-fcf5f4fb14453a0d.md): ClickHouse · 2022-12-07 · Medium · 17 min read · Query engines, Analytics & OLAP, SQL, Performance engineering
  ClickHouse dictionaries, in-memory key-value structures, can replace JOINs against small lookup tables.
- [ClickHouse Cloud: Fast, Updatable Lookups with the Join Table Engine](https://swe.quest/articles/clickhouse-cloud-fast-updatable-lookups-with-the-join-table-engine-b50f6e80ec781fcd.md): ClickHouse · 2026-05-12 · Medium · 6 min read · Analytics & OLAP, Databases, SQL, Cloud platforms
  ClickHouse's Join table engine keeps a precomputed in-memory hash map for a fixed join strictness, type and key.
- [Join me if you can: ClickHouse vs. Databricks vs. Snowflake - Part 2](https://swe.quest/articles/join-me-if-you-can-clickhouse-vs-databricks-vs-snowflake-part-2-66aede87450dc5eb.md): ClickHouse · 2025-06-25 · Medium · 8 min read · Analytics & OLAP, Performance engineering, Query engines, SQL
  Replacing fact-to-dimension joins with in-memory dictionaries in ClickHouse Cloud sped up a 17-query join benchmark over 1.4 billion rows by 1.9–3.5× in total runtime, up to 6.6× on individual queries, and cut cost by up to 60%.
- [Choosing the Right Join Algorithm](https://swe.quest/articles/choosing-the-right-join-algorithm-3a2fc89a0d23b80c.md): ClickHouse · 2023-06-27 · Medium · 13 min read · Query engines, Analytics & OLAP, Performance engineering, SQL
  ClickHouse offers six join algorithms (direct, hash, parallel hash, grace hash, full sorting merge, partial merge), and the right choice depends on speed, memory and supported join types.
- [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.

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)
