How we made ClickHouse UPDATEs 1,000× faster (Part 3: Benchmarks)
ClickHouse's new standard SQL UPDATEs, implemented as lightweight patch parts, make changes visible up to ~1,000–1,700× faster than classic mutations on a 600M-row TPC-H lineitem table: one bulk update dropped from about 100 s to 60 ms. The benchmark compares classic mutations, on-the-fly mutations, lightweight updates and ReplacingMergeTree inserts for both bulk and single-row updates, measuring time to visibility and worst-case query slowdown before merges. Lightweight updates add only about 12–15% average query overhead, rising to 39–121% in a rare join-mode fallback. On-the-fly mutations average 149% slowdown, and ReplacingMergeTree with FINAL averages about 280% slowdown with 20–200× the memory. ReplacingMergeTree inserts are the fastest way to write single rows, but lightweight updates give the best balance of write speed and query cost.
Related posts
- 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).
- ClickHouse Release 25.7
ClickHouse mediumAdept
ClickHouse 25.7 adds standard SQL UPDATE and DELETE built on lightweight "patch parts". Instead of rewriting columns, small immutable parts are applied during background merges and matched at query time, making declarative updates up to 1,000× faster in ClickHouse's benchmarks. count() GROUP BY aggregations now store the 64-bit count directly in the hash table cell, skipping the memory arena and pointer indirection, which cut query time ~34% and memory ~21% on a 100M-row benchmark. The release also brings four hash-join optimizations: tighter single-key loops, faster OR-condition joins, no repeated hashing, and precisely sized result buffers, worth roughly 1.4–1.8× speedups, plus AI-powered SQL generation in clickhouse-client via a `??` prefix.
- You can’t UPDATE what you can’t find: ClickHouse vs PostgreSQL
ClickHouse mediumAdept
ClickHouse 25.7's SQL-standard UPDATEs were benchmarked against PostgreSQL 17.5 on identical hardware using the 600M-row TPC-H lineitem table, with cold and hot runs. ClickHouse wins bulk updates by up to 4,000× because most bulk WHERE clauses can't use the primary key index. That forces full scans, where PostgreSQL takes 380–390 s and ClickHouse's columnar, parallel scan takes 0.09–5.23 s. Point updates are roughly at parity and cached point updates stay competitive. The comparison isn't apples-to-apples: PostgreSQL wraps every statement in a transaction and fsyncs WAL at commit by default, while ClickHouse skips per-statement transactions and defaults to fsync_after_insert=false.
- 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.
- Handling Updates and Deletes in ClickHouse
ClickHouse mediumAdept
ClickHouse offers several ways to modify mostly-immutable analytical data, each with different costs. Lightweight Deletes (DELETE FROM) write a _row_exists mask and rely on background merges to physically remove rows, which makes them cheap but leaves space reclamation non-deterministic. ALTER UPDATE/DELETE mutations rewrite whole parts, so they are heavy but guarantee removal, which matters for compliance. Cheaper alternatives cover specific cases: swapping in a new column with a DEFAULT for whole-table updates, Join engine plus joinGet for join-based updates, dropping partitions or using TTL for bulk and time-based deletion, and CollapsingMergeTree sign rows for frequent row-level updates.