B-trees and LSM-trees make different bets about where database work should happen. A B-tree keeps ordered keys in a balanced hierarchy of pages, updating that hierarchy in place. An LSM-tree accepts new data in memory, writes immutable sorted files, and later merges those files through compaction. The first approach usually gives predictable point and range reads; the second can turn many small random writes into sequential, batched work.
Neither architecture is universally faster. The right choice depends on your read/write mix, point-versus-range access, dataset size, memory, storage hardware, latency target, available disk headroom, and ability to operate compaction. This guide explains the mechanics and shows how to choose with measurements rather than slogans.
As an Amazon Associate I earn from qualifying purchases.
What the B-tree-versus-LSM-tree tradeoff actually is
A storage engine must maintain an ordered mapping from keys to records while serving reads, inserts, updates, deletes, crash recovery, and space reclamation. B-trees and LSM-trees place those costs in different parts of the system.
- B-tree: maintain one balanced, page-oriented search structure. A lookup follows pointers from a root through internal pages to a leaf. Updates modify pages and may split or merge them.
- LSM-tree: accept updates in an in-memory structure, flush immutable sorted files, and periodically merge files into larger runs. Reads search more than one structure unless compaction has consolidated them.
That placement creates the familiar tradeoff: B-trees tend to spend more work during individual updates, while LSM-trees defer work to background compaction and pay for it in read paths, temporary space, and operational complexity. The balance changes with implementation and hardware.
#1 Best Overall
- hardcover, brand new
How a B-tree stores and updates ordered data
Pages form a multi-way balanced tree
PostgreSQL 18 describes its B-tree index as a standard multi-way balanced tree. Its documentation also notes that sortable data types can use the index: PostgreSQL B-Tree Indexes. “Multi-way” means a page contains many keys and child pointers, so the tree remains shallow even when it contains millions of entries.
The root directs a search to an internal page; internal pages narrow the key range; a leaf page contains the indexed keys and references to table rows or records. Because leaves are ordered, an engine can walk adjacent leaf pages for a range scan instead of performing a separate lookup for every key.
What happens on an update
When an insert fits in a leaf page, the engine changes that page and records enough information for durability and recovery according to its own logging design. If the page is full, it can split the page and propagate a separator key upward. Deletes and updates can leave free space that is later consolidated or reused. The exact number and timing of physical writes depend on page size, caching, logging, checkpointing, fill-factor policy, and the implementation; there is no single universal “one update equals one page write” rule.
This in-place organization gives a point lookup a mostly fixed tree path. With useful pages in cache, the path can be short; when the working set exceeds memory, each uncached level may require an I/O. A range scan can follow linked or logically adjacent leaves and read a contiguous key interval.
How an LSM-tree turns writes into sorted files
Memtable first, SST files next
In RocksDB’s design, incoming writes are appended to a write-ahead log and applied to an in-memory memtable. When the memtable fills, it is flushed as an immutable sorted-string table (SST) file. The project overview explains that data is stored in SST files and that a full memtable is written to level 0: RocksDB Overview.
A read may therefore consult the current memtable, immutable memtables waiting to flush, and SST files. Bloom filters, indexes, block caches, and key-range metadata can rule out many files, but the engine still has more potential read locations than a single B-tree path.
Rank #2
- Brand: McGraw-Hill Education
- Database System Concepts, 7th Edition
Compaction merges runs and discards obsolete versions
Background compaction reads SST files, merges their sorted streams, and writes larger files into higher levels. During that merge it can remove overwritten values, tombstones whose deletion is safe to apply, and duplicate versions. Compaction keeps the number and overlap of files manageable, but it repeatedly reads and rewrites data that was already written once.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems“The overall write throughput of an LSM database directly depends on the speed at which compactions can occur, especially when the data is stored in fast storage like SSD or RAM.”
RocksDB project documentation, RocksDB Overview
That statement is the key qualification to the phrase “LSM has fast writes.” The foreground write path can be efficient, but sustained throughput is limited by whether compaction can keep up. If it falls behind, files accumulate, reads examine more levels, free space shrinks, and the engine may throttle or stall new writes.
Read behavior: point lookups and range scans are different
Point lookups
A B-tree normally follows one root-to-leaf route. An LSM engine checks its newest structures first and then consults SST files, using key ranges, Bloom filters, and block indexes to avoid unnecessary reads. A warm cache can make either design fast; a cold or oversized working set exposes the extra levels in an LSM.
One USENIX comparison reported 71,000 transactions per second for WiredTiger random point reads under 16 client threads, versus 57,000 for RocksDB and 57,000 for the study’s B-tree variant. Those are measurements from that paper’s dataset, cache, software versions, device, thread count, and query definition—not general performance promises. See “Revisiting B+-tree vs. LSM-tree upon the Arrival of Modern Storage Hardware”.
Recommended Free Tools
Ordered and range scans
Range scans expose the physical layout more directly. B-tree leaves provide one ordered traversal. An LSM scan may need to merge iterators from several levels and files, then resolve duplicate keys and tombstones. The same USENIX comparison found noticeably worse range-scan throughput for RocksDB than for the compared B-tree implementations because the scan read across LSM levels. The result is workload-specific, but it explains why a database that is excellent at ingestion can disappoint an analytics query that walks a large key interval.
Read amplification means the extra physical or logical reads needed to answer a query compared with an idealized single read. The boundary matters: one study may count device I/O, another may count blocks examined, and caching can change both. Treat the metric as a defined measurement, not a universal constant.
Write behavior and throughput
Why LSM writes can be efficient
Appending to a log and sorting in memory avoids many small random page updates. A flush writes a sequential SST run, and batches can amortize metadata and synchronization. This is attractive for ingestion, append-like events, and workloads that can tolerate delayed consolidation.
Why B-tree writes can still win
B-tree updates do not require a later full-level merge to become searchable. With a large cache, efficient page layout, parallel I/O, or storage that compresses pages transparently, the apparent advantage of an LSM can narrow or reverse.
In the cited USENIX experiment, the study’s B-tree variant delivered 19% higher random-write throughput than RocksDB and about 2.1 times the throughput of WiredTiger under that paper’s configuration. The comparison is useful evidence that modern B-tree techniques matter, not a claim that every B-tree beats every LSM.
| Reported result | What it measured | Qualification |
|---|---|---|
| 71K TPS | WiredTiger random point reads with 16 client threads | USENIX study configuration; compared with 57K TPS for RocksDB and the study’s B-tree variant |
| 19% higher | Random-write throughput of the study’s B-tree variant versus RocksDB | Specific dataset, software, device, cache, and workload |
| About 2.1× | Random-write throughput of the study’s B-tree variant versus WiredTiger | Same study conditions; not a general engine ranking |
| Over 10× reduction | B-tree write amplification using specialized techniques | Measured on a commercial drive with built-in transparent compression in the VLDB paper’s setup |
Write amplification, read amplification, and space amplification
Write amplification is the amount of data physically written for a logical insert or update workload. Read amplification is the extra reading required to serve a query. Space amplification is the extra storage occupied by duplicate versions, temporary files, metadata, or other overhead beyond the live logical dataset. The exact measurement boundaries differ across engines and studies.
The FAST 2016 analysis treats read and write amplification as amortized I/O metrics related to query cost, insertion throughput, and flash-drive endurance estimates: “Write Amplification Analysis in Log-Structured Merge Trees.” An LSM can write the same logical bytes several times as they move through levels. A B-tree can write pages repeatedly because of updates, splits, logging, and checkpoint policy.
Do not compare an amplification number without checking what was counted, which workload produced it, and whether compression was enabled. A paper titled “Closing the B-tree vs. LSM-tree Write Amplification Gap on Modern Storage Hardware with Built-in Transparent Compression” reported more than a tenfold reduction in B-tree write amplification from specialized techniques on a drive with transparent compression. That result demonstrates how implementation and device features change the tradeoff; it is not ordinary B-tree behavior on every disk.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Compaction style changes the LSM tradeoff
Level-style compaction
In level-style compaction, a file is merged with overlapping files in the next level. The result is usually a controlled number of files and a compact representation of the logical database. RocksDB documents this approach as optimizing disk footprint relative to logical database size by merging overlapping data into larger levels.
The cost is repeated rewriting: a hot key range can be merged through several levels, increasing write amplification. During a merge, the engine also consumes read bandwidth, CPU, and temporary output space.
Universal-style compaction
Universal compaction groups sorted runs more broadly. It typically lowers write amplification but raises read and space amplification compared with level style, and it may need more temporary space. The choice is therefore a policy decision, not a claim that one compaction mode is “best.” The compaction design space is analyzed in “Constructing and Analyzing the LSM Compaction Design Space.”
| Compaction choice | Typical advantage | Typical cost | Consider when |
|---|---|---|---|
| Level style | Lower read and space amplification | More rewriting and potentially higher write amplification | Reads and predictable footprint matter, and storage can sustain merges |
| Universal style | Lower write amplification | Higher read and space amplification; more temporary headroom may be required | Ingestion and write endurance dominate, and extra space is available |
RocksDB defaults and controls vary by version and configuration. Before changing compaction settings, verify the deployed release, workload, level sizes, file limits, compression, and available free space.
Storage hardware can overturn old assumptions
Older comparisons often assumed that random writes were dramatically more expensive than sequential writes. Modern NVMe devices, parallel I/O, larger memory, transparent compression, and improved filesystems narrow some of that gap. Conversely, a device with limited write endurance or low parallelism can make repeated compaction especially painful.
Best Value
Measure the characteristics that affect your engine: sustained random and sequential bandwidth, latency under queue depth, durability behavior, compression support, usable capacity, and performance when nearly full. A fast device does not eliminate compaction; it can make compaction the dominant consumer of bandwidth because the foreground path becomes faster.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Operational costs you must plan for
LSM monitoring and controls
- Track pending compaction work, oldest unmerged data, file counts by level, flush latency, and write-stall events.
- Reserve free space for overlapping input and output files during compaction. A volume that fits the logical dataset may still be too small.
- Observe p95 and p99 read and write latency while compaction runs, not only idle throughput.
- Set background thread and rate controls so compaction cannot starve foreground reads, but validate that throttling does not create an unbounded backlog.
- Test recovery time after an unclean shutdown, including replay of the log and reopening many SST files.
B-tree monitoring and controls
- Watch page-split rates, cache hit ratios, dirty-page pressure, checkpoint duration, and index or table bloat.
- Choose page and fill-factor policies with the actual key distribution; monotonic inserts and random updates stress different parts of the tree.
- Measure lock contention and tail latency when many clients update nearby key ranges.
- Plan maintenance for reclaiming dead versions or fragmented pages according to the engine’s visibility and vacuum model.
- Test backup, restore, and crash recovery with a full-size tree, not just a small development database.
Both architectures need observability. An LSM exposes compaction debt; a B-tree exposes page locality, splits, cache pressure, and maintenance work. The operational burden is different rather than absent.
Choose by workload, not by architecture slogan
| Workload characteristic | Possible lean | Reason and caution |
|---|---|---|
| Heavy ingestion, append-like or batched writes | LSM may fit | Sequential flushes can absorb bursts, provided compaction keeps up and space headroom exists |
| Frequent ordered scans and index-range queries | B-tree may fit | Leaf ordering can avoid merging many LSM runs; benchmark the real query shapes |
| Read-heavy point lookups with a hot working set | Either | Cache behavior and filters may dominate the theoretical difference |
| Large random updates with strict tail-latency limits | Depends | Compare page contention and splits against compaction stalls under p95/p99 load |
| Limited disk capacity | Often B-tree or tightly controlled level-style LSM | Universal compaction and in-flight merges can require substantial temporary space |
| Storage with transparent compression or high parallel I/O | Re-measure both | Hardware can reduce B-tree write amplification or accelerate compaction enough to change the result |
A practical benchmark before committing
When the choice affects a production migration, build a representative test instead of extrapolating from a headline number.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11- Capture the access mix. Record the percentage of inserts, updates, deletes, point reads, and range scans. Include key-size and value-size distributions, not just averages.
- Scale the dataset. Test at least one working set that fits in memory and one that substantially exceeds it. Include the expected growth point.
- Replay realistic bursts. Run steady load, bursty ingestion, update-heavy periods, and mixed read/write traffic. Keep client concurrency and durability settings explicit.
- Measure tails and background work. Record throughput, p50/p95/p99 latency, compaction or maintenance bandwidth, cache misses, stalls, and space consumed over time.
- Fill the device. Test with production-like free-space margins. Compaction behavior near capacity can differ sharply from an empty-volume test.
- Repeat after warm-up and recovery. Compare cold start, warm cache, restart, crash recovery, backup, and restore. A design that wins steady-state throughput may lose its recovery objective.
- Validate query plans. Confirm that range scans, prefix scans, pagination, and point lookups use the intended indexes and do not hide extra work in the application.
Two illustrative workload decisions
Telemetry ingestion with occasional recent-data queries
Suppose a service appends timestamped events in batches, keeps a large history, and mostly queries recent windows. An LSM can be attractive because memtable flushes and sequential SST writes absorb ingestion. The design is acceptable only if compaction bandwidth, temporary space, and read latency for the recent-window queries remain within budget. Test retention deletes and tombstone cleanup as part of the workload; they can create additional compaction work.
Account directory with many ordered reports
Suppose an application updates user records throughout the day and frequently scans by account number, region, or date for reports. A B-tree’s ordered leaves may provide simpler range access and steadier scan behavior. That advantage can disappear if random page updates cause cache thrashing or splits, so measure concurrent writes and tail latency rather than assuming the tree will be cheap.
Common mistakes and how to avoid them
- “LSM means fast writes forever.” Sustained throughput is bounded by flush and compaction capacity. Watch backlog and stalls.
- “B-tree means one physical write per update.” Logging, checkpoints, page splits, caching, and recovery policy determine actual I/O.
- “Range scans are just many point reads.” B-tree leaf traversal and LSM multi-run merging have different costs; benchmark scan length and selectivity.
- “One amplification figure applies everywhere.” State the workload, counting method, compression, cache, and device for every number.
- “A benchmark ranking transfers to another engine.” Software versions, page formats, filters, compaction settings, and query definitions can reverse results.
- “Disk capacity equals dataset size.” LSM compaction needs input and output headroom; B-trees need room for logs, indexes, and maintenance.
- “Defaults are permanent.” Verify the release and configuration deployed in production before relying on a compaction or cache behavior.
Bottom line
A B-tree keeps ordered data in a balanced page hierarchy, favoring direct point paths and naturally ordered scans. An LSM-tree makes writes cheap to accept by buffering them and writing sorted files, then pays for that choice through compaction, extra read paths, and temporary space. Compaction style, compression, memory, and storage hardware can materially change the balance.
Choose an LSM when your ingestion pattern benefits from batching and you can fund compaction and its space requirements. Choose a B-tree when ordered access and predictable read paths dominate, or when your hardware and implementation eliminate the expected write disadvantage. In either case, use representative data, mixed workloads, and tail-latency measurements before making the storage-engine decision.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

