Skip to content

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

RocksDB Blog 8 min read Deep dive hardMaster

Range Tombstone Conversion: Faster Scans Over Long Runs of Deletes

RocksDB 11.3.0 adds range tombstone conversion: when a read iterator walks a run of contiguous point tombstones with no live key between them, it inserts one redundant range tombstone [first_tombstone_key, next_live_key) into the memtable at the iterator's snapshot sequence number. Later scans then skip the run in one hop instead of O(N) steps. Only the iterator can do this safely, because it merges every memtable and SST level, while flush and compaction see only part of the LSM and could shadow live keys at other levels. The feature is off by default and enabled with the dynamic option min_tombstones_for_range_conversion. db_bench shows ~99x faster forward and ~368x faster reverse scans over delete-heavy data, with no regression when there are no tombstones.

Assumes: LSM-tree basicsRocksDB compaction and memtablestombstones and snapshots

Related posts

  • Persistent Structures: Key to 2000x Speedup in Neon’s WAL Indexing

    Neon hardMaster

    Neon's pageserver must answer GetPage(key, LSN) by finding, for a point in key–LSN space, the first image or delta layer rectangle directly below it, across tens of millions of layers. Linear scans and R-trees degrade to O(N), and a 2D segment tree would need balancing and lazy propagation that blow the complexity budget. Neon instead precomputes a "layer coverage" BST for the latest LSN and makes it persistent (copy-on-write) with the rpds crate, inserting layers bottom-up so every historical LSN has its own queryable version. Construction and space are O(N log N), queries are O(log N), and the result is 70x faster than the R-tree on real databases and 2000x on larger synthetic ones.

  • Postgres Bloat Minimization

    Supabase mediumAdept

    Postgres stores table rows in 8KB heap pages and writes a new row version on every update, so dead versions accumulate until vacuum reclaims them and updates the free-space and visibility maps. Bloat usually means autovacuum never started, because the default 20% scale factor is too high for large tables, or it started but couldn't finish because of long-running idle transactions or SHARE UPDATE EXCLUSIVE locks. The fixes include lowering per-table scale factors, setting idle_in_transaction_session_timeout, cancelling stuck backends, and raising autovacuum_max_workers or autovacuum_work_mem. VACUUM FULL or pg_repack returns space to the filesystem after mass deletes; VACUUM FULL takes an exclusive lock and pg_repack does not.

  • Supabase Storage: major performance, security, and reliability updates

    Supabase mediumAdept

    Supabase Storage replaces its trigger-maintained prefixes table with a hybrid skip-scan algorithm that derives folder structure at read time, and switches from OFFSET to cursor-based pagination, making deep pagination up to 14.8x faster on 60 million rows with no write penalty. The release also closes a file-backend path traversal bug and blocks direct SQL DELETEs on storage tables that orphaned S3 objects. It adds Postgres query cancellation on client disconnect, idempotent migrations verified by pg_dump comparison, a fix for a TUS S3 lock renewal race, and a move from prom-client to OpenTelemetry metrics. No code changes are required, though switching to the listV2 endpoint is recommended.

  • Birth and death of a row in Turso's MVCC

    Turso hardMaster

    Turso's MVCC, modeled on Hekaton, tracks each row as a chain of versions in a lock-free SkipMap, with begin/end fields holding a TxId while a transaction is active and a commit timestamp once it commits. The walkthrough follows one row from the INSERT bytecode executed by the VDBE, through the commit protocol (timestamp acquisition, first-committer-wins conflict checks, dependency waits, logical-log write and fsync), crash recovery by replaying the logical log, and checkpointing into the SQLite WAL and B-tree. Checkpoints default to a blocking Truncate mode triggered at about 4 MB, with an experimental Passive mode that lets writers proceed. Reads merge the in-memory store and the B-tree with a two-pointer iteration. Deletes set the end field under the version-chain lock, so concurrent writers to the same row get a WriteWriteConflict.

  • Streaming secondary indices: incremental, demand-driven index evaluation

    ClickHouse mediumAdept

    ClickHouse 25.9 introduces streaming secondary indices, which check skip-index entries (minmax, set, bloom filter, vector, text) incrementally as each table granule is about to be read, instead of scanning the whole index before query execution. Interleaving index checks with data reads removes the startup delay and lets queries with LIMIT stop both index scanning and granule reads as soon as the result is complete. On a one-billion-row table with a 2.2 GiB bloom filter index, a LIMIT 1 needle lookup dropped from ~10.2s to ~2.5s and peak memory halved. The feature is controlled by the use_skip_indexes_on_data_read setting.

The quest for software engineering knowledge.

Look:
Layout: