Skip to content

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

ClickHouse 24 min read Deep dive mediumAdept

ClickHouse Cloud boosts performance with SharedMergeTree and Lightweight Updates

SharedMergeTree is a new ClickHouse Cloud table engine that replaces ReplicatedMergeTree (and its zero-copy replication variant) by moving both data and part metadata off the servers into shared object storage and ClickHouse Keeper. Servers become stateless compute nodes: they cache subsets of metadata locally and learn about new parts through Keeper subscriptions rather than a replication log and exclusive locks. New nodes can join almost instantly, and inserts are durable once the part is in object storage and its metadata is in Keeper. This removes the replication-log contention and local-disk dependencies that limited scaling beyond a few replicas. Lightweight updates are introduced alongside and benefit from the shared-metadata design.

Related posts

  • No more disks: the architecture behind stateless compute in ClickHouse Cloud

    ClickHouse hardMaster

    ClickHouse Cloud compute nodes are now fully stateless and diskless. The last local dependency, database metadata stored as .sql files, has been removed by a new in-memory Shared database engine backed by a versioned Shared Catalog in Keeper. The architecture got there in stages: SharedMergeTree moved table data to object storage, a distributed cache plus a userspace page cache replaced node-local caching, and the Shared Catalog replaced the Atomic and Replicated database engines. Centralized metadata enables fast bootstrapping without warm-up and DROP operations that don't require every node to be online. It also adds new DDL such as atomic INSERT … SELECT, cross-database RENAME and UNDROP, with selective invalidation of conflicting DDLs instead of a global lock, and extends stateless compute to Iceberg and Delta Lake.

  • How we built fast UPDATEs for the ClickHouse column store – Part 1: Purpose-built engines

    ClickHouse mediumAdept

    ClickHouse avoids slow in-place row updates in its column store by expressing updates and deletes as inserts that get resolved during the background merges MergeTree already performs. Sorted, immutable data parts can be merged in a single linear pass, so keeping only the latest version adds almost no overhead. ReplacingMergeTree keeps the latest full row per sorting key, CoalescingMergeTree merges sparse partial updates using Nullable columns, and CollapsingMergeTree cancels rows with a sign column, which also lets it change sorting key values. All three give UPSERT semantics but are only eventually consistent, so queries that need current results use FINAL to apply the merge logic in memory at read time.

  • 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.

  • Clone massive tables instantly and experiment safely in ClickHouse

    ClickHouse mediumAdept

    ClickHouse's `CREATE TABLE ... CLONE AS` creates a full, independent copy of a table almost instantly, without copying any data. It can do this because MergeTree data parts are immutable. Each part directory in the clone hard-links to the source's files, using POSIX hard links locally or metadata indirection on S3. Any later insert, update, delete or merge writes new parts, which gives part-level copy-on-write. Cloning time grows with part count rather than data size, the clone uses almost no extra storage until either table diverges, and shared files stay on disk until nothing references them. That makes clones safe for destructive tests, schema experiments, backfills and migrations.

  • How we built fast UPDATEs for the ClickHouse column store – Part 2: SQL-style UPDATEs

    ClickHouse hardMaster

    ClickHouse implemented standard SQL UPDATE in its MergeTree column store by evolving from classic mutations (which rewrite whole affected columns and hard-link unchanged ones) through lightweight DELETEs via a _row_exists mask column and on-the-fly in-memory updates, to patch parts. A patch part is a compact delta containing only changed column values plus _part and _part_offset metadata. It is visible to queries immediately and applied during normal background merges in a single linear pass, with no resorting or extra indexing. This avoids full column rewrites and blocking on prior merges, making frequent row-level updates practical (experimental in 25.7, beta expected in 25.8).

The quest for software engineering knowledge.

Look:
Layout: