1. The Mutation Bottleneck: Why ClickHouse Struggles with Updates
ClickHouse is revered in the data engineering world for good reason: when fed immutable, append-only event data, its MergeTree engine delivers unmatched scan and aggregation speeds.
However, modern applications frequently require modifying existing data: updating user profile fields, toggling order statuses (PENDING → COMPLETED), GDPR 'Right to be Forgotten' user deletions, or financial adjustments. In ClickHouse, modifying data exposes fundamental architectural tradeoffs:
- Heavyweight Asynchronous Mutations: Standard SQL
UPDATEandDELETEstatements in ClickHouse are translated into asynchronous mutations (ALTER TABLE ... UPDATE/DELETE). These operations do not modify rows in-place; instead, a background worker must completely rewrite entire immutable data parts on disk. - Write Amplification and Lock Contention: High-frequency mutations create severe write amplification. Disk I/O and CPU utilization spike dramatically, and subsequent mutations queue up behind in-flight part rewrites, leading to replication lag and delayed visibility.
- Workarounds with Tradeoffs: ClickHouse users often resort to specialized engines like
ReplacingMergeTreeorCollapsingMergeTree. While clever, these require deferring final deduplication until query time (e.g., usingFINAL), which degrades analytical scan performance by 2× to 10×.