Skip to content

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

ClickHouse 8 min read Research mediumAdept

Join me if you can: ClickHouse vs. Databricks vs. Snowflake - Part 2

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%. The Locations table becomes a complex_key_hashed dictionary for String-key lookups. The Products table becomes a range_hashed dictionary that resolves time-versioned rows with a hash map plus binary search over date ranges, provided the source has no overlapping ranges per key. Queries change only by swapping JOINs for dictGet calls, and the gains grew as the cluster scaled from 2 to 8 nodes.

Assumes: SQL joinsstar schema data modelingcolumnar OLAP databases

Related posts

  • Using Dictionaries to Accelerate Queries

    ClickHouse mediumAdept

    ClickHouse dictionaries, in-memory key-value structures, can replace JOINs against small lookup tables. Using the NOAA weather dataset, a normalized INNER JOIN against a stations table forces a full scan of 1.08 billion rows because ClickHouse runs joins before WHERE filtering. Swapping in dictGet lookups alongside a primary-key-friendly subquery brings that query back to millisecond latency. The post walks through creating a dictionary, choosing a layout (flat, hashed, hashed_array, complex_key variants, sparse), setting LIFETIME and invalidate_query for refreshes, and loading data, recommending hashed_array or complex_key_hashed_array for most cases.

  • Join me if you can: ClickHouse vs. Databricks vs. Snowflake - Part 1

    ClickHouse easyNovice

    ClickHouse Cloud ran a third-party, join-heavy coffee-shop star-schema benchmark (17 queries, originally built to compare Databricks and Snowflake) with no query rewrites or tuning, and came out faster and cheaper at every scale from 721 million to 7.2 billion rows. At the 500m scale most queries finish in under a second, 3–5× faster than the alternatives. At the 1b scale one query joins, aggregates and sorts 1.7 billion rows in half a second where the other systems take 5–13 seconds. The setup used shared-data compute warehouses with parallel replicas on 2–16 nodes, reported the best of 5 warm runs, and is reproducible from a public repo and S3 dataset.

  • ClickHouse Joins Under the Hood - Direct Join

    ClickHouse mediumAdept

    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.

  • ClickHouse Cloud: Fast, Updatable Lookups with the Join Table Engine

    ClickHouse mediumAdept

    ClickHouse's Join table engine keeps a precomputed in-memory hash map for a fixed join strictness, type and key. With ANY LEFT strictness, inserts behave as upserts, which suits Type 1 slowly changing dimensions as an updatable alternative to Dictionaries, queried via Direct Join or joinGet. In open source the engine isn't distributed and persists each insert as an uncompacted .bin file, which degrades over time. ClickHouse Cloud transparently backs Join tables with a SharedJoin over a MergeTree (ALL) or ReplacingMergeTree (ANY) table, refreshing memory with a FINAL query on insert and startup, so deduplication, compaction and clustering are handled automatically.

  • Trade secrets: How Coinhall uses ClickHouse to power its blockchain data platform

    ClickHouse easyNovice

    Coinhall, an omnichain trading terminal aggregating swap data from 23 blockchains, moved from BigQuery (about 2-second queries, thousands of dollars per month) to QuestDB and then to self-hosted ClickHouse. In Coinhall's comparison against Rockset, SingleStore and Snowflake, ClickHouse ran candlestick queries in 20 ms, latest-price queries in 8 ms and ASOF JOINs in 50 ms, on a 4 vCPU / 16 GB server costing about $50 a month. After migrating, the team tuned queries around sparse primary indexes and replaced full-table LIMIT BY scans with aggregating tables fed by materialized views. They also avoided or simplified sort-merge joins.

The quest for software engineering knowledge.

Look:
Layout: