AlgoMaster Logo

LSM Trees (Log-Structured Merge Trees)

Last Updated: May 26, 2026

Ashish

Ashish Pratap Singh

Medium Priority
10 min read

B+ trees are a strong default for read-heavy and mixed OLTP workloads. They keep index entries ordered in page-sized structures, which gives predictable point lookups and efficient range scans.

The write path has a cost. Updating a B+ tree usually modifies pages in place. An insert may dirty a leaf page, update parent pages, write WAL records, and occasionally split pages. That cost is manageable for many transactional systems, but it becomes painful when the workload is dominated by sustained writes.

LSM trees take a different approach. They buffer writes in memory, write sorted immutable files to disk, and merge those files in the background.

LSM trees make foreground writes cheap by moving much of the cleanup work to reads and compaction.

This design powers storage engines such as LevelDB, RocksDB, Cassandra, ScyllaDB, Bigtable, and HBase. It also appears in search systems through immutable segment designs such as Lucene, although Lucene is not a general-purpose key-value LSM tree.

1. The Problem with B+ Trees

Premium Content

This content is for premium members only.