Skip to content

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

ClickHouse 6 min read Announcement mediumAdept

ClickHouse Newsletter April 2023: Lightweight Deletes

ClickHouse 23.3 makes lightweight deletes (DELETE FROM with a row condition) generally available and the preferred way to remove data, and also adds trace visualization to the Grafana plugin and parallel replicas that split a shard's data across replicas. Lightweight deletes simplify incremental updates of denormalized, JOIN-materialized tables. Instead of copying the whole target table while excluding changed ids and then swapping it in with EXCHANGE, changed rows go into a temporary table, are deleted from the target by id, and are re-inserted. The dbt-clickhouse plugin now recommends this approach for incremental materializations.

Assumes: ClickHouse basicsmaterialized tables via INSERT INTO SELECT

Related posts

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

  • ClickHouse and dbt - A Gift from the Community

    ClickHouse mediumAdept

    The dbt-clickhouse adapter, started by community contributor Dmitriy Sokolov and later taken over as a vendor-supported plugin, maps dbt's view, table, incremental and ephemeral materializations onto ClickHouse features. The default incremental strategy builds a temporary table of changed rows, copies all unchanged rows into a new table and atomically swaps it in, which duplicates the whole dataset on every run. A newer delete+insert strategy uses ClickHouse 22.8's experimental lightweight deletes (tombstones removed during merges) to write only the changed rows and performs significantly better. Its caveats: it needs the experimental setting enabled, and because it modifies the target table directly with no transaction, a failure can leave the model in an invalid state.

  • ClickHouse Release 23.3

    ClickHouse mediumAdept

    ClickHouse 23.3 LTS adds parallel replicas, which let multiple replicas of the same shard each process distinct data ranges assigned by an initiator node. This allows query speed to scale by adding replicas, especially on shared object storage, without resharding. Dynamic shards via parallel_replicas_custom_key split work with modulo or range predicates, which can skip the final GROUP BY merge. Lightweight deletes are now GA but only remove rows from disk during later merges, so mutations remain the choice for immediate space recovery or compliance. The release also adds MySQL-compatible parseDateTime and Joda-syntax parsing, plus Grafana visualization of query traces from opentelemetry_span_log.

  • ClickHouse Release 26.3

    ClickHouse mediumAdept

    ClickHouse 26.3 ships 27 features, 40 performance optimizations and 202 bug fixes. Headline changes are asynchronous inserts enabled by default, JOIN reordering for ANTI/SEMI/FULL joins, and MATERIALIZED CTEs, which evaluate a WITH subquery once into a temporary table. In a UK property-prices example, materializing the CTE roughly halved query time and cut peak memory from 1.5 GiB to about 88 MiB. The release also adds pretty/compact EXPLAIN output, naturalSortKey, JSONExtract support for the JSON type, and experimental WebAssembly UDFs sandboxed with Wasmtime. TTL DELETE can now use vertical merges, and the post explains how horizontal and vertical merges work and when each is chosen.

  • ClickHouse is data lake ready

    ClickHouse mediumAdept

    ClickHouse now queries Apache Iceberg and Delta Lake tables in place on S3, GCS and Azure, either directly or through catalogs such as AWS Glue, Unity, Polaris, BigLake, OneLake and Iceberg REST. Teams can load lake data into the native MergeTree engine when they need sub-second, high-concurrency queries, and can write results back to open formats. The groundwork took two years of releases: a native Parquet reader with page-level parallelism that reads about 1.8x faster on ClickBench, integration of the Delta Rust Kernel, Iceberg time travel and DML, and parallel replicas. Worked examples against a 1.29-billion-row NYC taxi Iceberg table show in-place scans taking 50 to 130 seconds before ingestion into MergeTree for faster querying.

The quest for software engineering knowledge.

Look:
Layout: