Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

B-trees and LSM-trees make different tradeoffs between update cost, read work, space, and operational complexity. A B-tree keeps ordered keys in a balanced hierarchy of pages, so lookups and range scans follow a compact tree. An LSM-tree accepts writes into memory, flushes immutable sorted files, and later merges those files through compaction. That usually makes sustained ingestion attractive, but compaction adds background I/O and can increase read and space amplification.

Neither design is universally faster. The right choice depends on your read/write ratio, point-versus-range access pattern, dataset size, memory budget, storage hardware, latency objectives, and ability to operate and tune the engine.

What storage-engine tradeoff do B-trees and LSM-trees represent?

Both structures maintain ordered data, but they organize updates differently. A B-tree updates the tree in place by locating the relevant page and maintaining balance as keys are inserted, changed, or removed. An LSM-tree treats new data as a sequence of immutable sorted runs: recent writes land in memory, are flushed to sorted-string-table (SST) files, and are merged in the background.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The central tradeoff is when the engine pays the work required to keep data searchable. B-trees pay more of that cost during each update, while LSM-trees defer much of it to flushes and compaction. Deferral can turn many small random writes into larger sequential operations, but the deferred work still consumes CPU, storage bandwidth, and temporary space. It can also make reads check more than one location.

#1 Best Overall
Sale
Samsung SSD 990 PRO 2TB, PCIe 4.0 M.2 2280, Up to 7,450 MB/s | NVMe Internal Solid State Hard Drive for High End Computing, Gaming, and Heavy Duty Workstations, (MZ-V9P2T0B/AM)
  • MEET THE NEXT GEN: Consider this a cheat code; Our Samsung 990 PRO Gen4 SSD helps you reach near max performance with lightning-fast speeds; Whether you’re a hardcore gamer or a tech guru, you’ll get power efficiency built for the final boss
  • REACH THE NEXT LEVEL: Gen4 steps up with faster transfer speeds and high-performance bandwidth; With a more than 55% improvement in random performance compared to 980 PRO, it’s here for heavy computing and faster loading
  • THE FASTEST SSD FROM THE WORLD'S FLASH MEMORY BRAND: The speed you need for any occasion; With read and write speeds up to 7450/6900 MB/s you’ll reach near max performance of PCIe 4.0 powering through for any use
  • PLAY WITHOUT LIMITS: Give yourself some space with storage capacities from 1TB to 4TB; Sync all your saves and reign supreme in gaming, video editing, data analysis and more
  • IT’S A POWER MOVE: Save the power for your performance; Get power efficiency all while experiencing up to 50% improved performance per watt over the 980 PRO; It makes every move more effective with less consumption

That is why “LSM is faster for writes” and “B-tree is faster for reads” are useful starting hypotheses, not guarantees. Implementations, cache sizes, query shapes, storage devices, compression, and compaction policy can reverse the result.

How a B-tree stores and updates ordered data

Balanced, page-oriented search

PostgreSQL 18 documents its B-tree index as a standard multi-way balanced tree. It supports sortable data types, allowing the index to organize keys and answer equality, ordering, and range predicates. The index is made of pages arranged in levels: a root directs the search to an internal page, which directs it toward a leaf page containing the relevant key entries.

Because the tree remains balanced, paths from the root to leaves have similar lengths. A point lookup follows one path through the hierarchy; an ordered scan walks adjacent leaf entries after finding the starting key. The number of pages touched depends on tree height, caching, key distribution, and the query, rather than on a single universal page count.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read the PostgreSQL description of this structure in the PostgreSQL 18 B-Tree Indexes documentation.

What an update costs

An insert or update finds the target leaf, modifies it, and may split a full page. A split can propagate toward the root, while deletion and maintenance can leave pages with free space that later needs reclaiming. The exact write and recovery behavior depends on the database’s page format, logging, checkpointing, caching, and maintenance algorithms; there is no single B-tree rule that every engine follows for the number of physical writes per logical update.

B-tree locality is valuable when a workload repeatedly reads neighboring keys. Once the relevant leaf pages are cached, a range scan can proceed through ordered pages with relatively little search overhead. Random updates, however, may touch many different pages, especially when the working set is larger than memory.

How an LSM-tree stores and updates ordered data

Memtables turn updates into sequential file creation

In an LSM design such as RocksDB, a write is first recorded in a memtable, an in-memory sorted structure. When the active memtable fills, it becomes immutable and is written as an SST file. The database’s durable representation is therefore a collection of immutable, sorted files rather than one continually modified tree.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Kingston NV3 1TB M.2 2280 NVMe SSD | PCIe 4.0 Gen 4x4 | Up to 6000 MB/s | SNV3S/1000G
  • Ideal for high speed, low power storage
  • Gen 4x4 NVMe PCle performance
  • Up to 6,000MB/s read, 4,000MB/s write
  • Includes Acronis cloning software
  • 5-year limited warranty

The RocksDB project overview describes this flow: a full memtable is written to level 0, and background compaction reads and merges files into larger files and higher levels. Immutable files avoid in-place modification, which can make bursts of random updates easier to absorb and batch.

RocksDB states the operational implication directly: “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.” The statement appears in the project’s RocksDB Overview.

Reads search multiple structures

A point lookup may need to check the current memtable, older immutable memtables, and SST files whose key ranges could contain the requested key. Bloom filters, indexes, caches, and compaction reduce unnecessary file reads, but they do not remove the underlying possibility of multiple checks.

A range scan must merge sorted results from the structures that overlap the requested interval. Before compaction has consolidated files, the iterator may read across several levels or files and reconcile newer versions with older ones. This is why an LSM can have excellent ingestion throughput while showing less predictable scan latency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compaction removes history and creates new files

Compaction merges SST files, keeps the newest visible version of a key, and discards obsolete or overwritten records when it is safe to do so. The output is written as new, larger SST files. Compaction therefore pays the deferred organization cost with additional reads and writes, CPU time, and temporary storage.

Compaction can run continuously, compete with foreground queries, or fall behind during an ingest burst. Engines may respond to a backlog with throttling or write stalls. The practical write rate is thus constrained not only by the foreground append path but also by the device and CPU capacity available to compaction.

Read amplification, write amplification, and space amplification

Write amplification is the amount of data physically written for a logical insert or update workload. An LSM may write a record when it enters a log or memtable, write it again when flushed, and rewrite it during one or more compactions. A B-tree can also write more physical bytes than the logical change because of page updates, splits, logging, and checkpoints.

Rank #3
Sandisk Optimus 5100 500GB NVMe SSD, PCIe 4.0, M.2 2280 | Up to 6,600MB/s Read Speeds, Up to 5,600MB/s Write Speeds, Internal Solid State Drive - SDSP51500GAN
  • SPEED UP PROJECTS. Launch creator applications fast with uncompromising PCIe 4.0 read speeds up to 7,100MB/s,[2] (1TB and 2TB[1] models) and write speeds up to 6,700MB/s[2] (1TB[1]-4TB[1] models).
  • CREATE AND STORE MORE. Make more room for your 4K videos and high-resolution images with capacities from 500GB[1] up to 4TB[1] on M.2 2280 built with our trusted 8th generation SANDISK BiCS QLC 3D CBA NAND.
  • IT GOES WHERE YOU GO. With an all-new power efficient design, your drive delivers high performance with low power, giving you more time to be productive while on the go.
  • UNCOMPROMISED RELIABILITY. With up to 1,200 TBW[3] (4TB[1] model) endurance rating, your drive is designed for creators.
  • KEEP YOUR DRIVE UPDATED. Monitor your SSD’s performance and check for updates with the downloadable SANDISK Dashboard application.[5]

Read amplification is the extra read work needed to answer a query beyond the logical data returned. In an LSM, this can come from checking multiple memtables and SST levels or merging overlapping runs. A B-tree’s amplification is associated mainly with traversing tree pages and fetching uncached leaves.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Space amplification is the amount of physical storage occupied relative to the live logical dataset. Old versions, overlapping files, indexes, free space, and temporary compaction output can all increase it. Definitions and measurement boundaries differ among engines and studies, so amplification numbers should only be compared when workload, configuration, and accounting rules match. The USENIX FAST 2016 paper treats read and write amplification as amortized I/O metrics connected to query cost, insertion throughput, and flash-drive endurance estimates; see Write Amplification Analysis in Log-Structured Merge Trees.

Read behavior: point lookups are not range scans

Point lookups

For a point query, a well-indexed B-tree follows one root-to-leaf path. An LSM may need to test several candidate structures, but file-level indexes, Bloom filters, block caches, and recent compaction can make those checks inexpensive. The result depends strongly on how much of the index and data fits in memory and how many files overlap the key.

Do not infer point-read speed from write throughput. A system optimized for ingestion may spend more CPU or I/O assembling the answer to a single lookup, while a B-tree optimized for direct navigation may spend more effort maintaining pages during writes.

Ordered and range scans

Range scans expose the difference more clearly. B-tree leaves are already linked by key order in many implementations, allowing a scan to advance through nearby pages. An LSM scan must merge sorted runs and apply version visibility while traversing files that overlap the range. More levels and overlapping files generally mean more read work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In a USENIX comparison, RocksDB’s range-scan throughput was noticeably worse than the compared B-tree implementations because the scan read across LSM levels. That result belongs to the study’s dataset, cache, thread counts, devices, software versions, and query definitions; it is evidence about that configuration, not a universal ranking.

What benchmark results actually show

The following figures come from a USENIX Association comparison published around 2022, using the paper’s own workload and system configuration:

Rank #4
Sale
Samsung SSD 990 PRO 1TB, PCIe 4.0 M.2 2280, Up to 7,450 MB/s | NVMe Internal Solid State Hard Drive for High End Computing, Gaming, and Heavy Duty Workstations (MZ-V9P1T0B/AM)
  • HUGE SPEED BOOST: Get random read/write speeds that are 40%/55% faster than 980 PRO; Experience up to 1400K/1550K IOPS, while sequential read/write speeds up to 7,450/6,900 MB/s reach near the max performance of PCIe 4.0*
  • BREAKTHROUGH POWER EFFICIENCY: Use less power and get more performance; Enjoy up to 50% improved performance per watt over 980 PRO, plus optimal power efficiency with max PCIe 4.0 performance**
  • SMART THERMAL CONTROL: Samsung's own nickel-coated controller delivers effective thermal control; With its slim size, 990 PRO is a perfect fit for desktops and laptops that meet the PCI-SIG D8 standard***
  • THE CHAMPION MAKER: Up to 65% improvement in random performance enables faster loads for an ultimate gaming experience on PS5 and DirectStorage PC games****
  • SAMSUNG MAGICIAN SOFTWARE: Get the most out of your SSD with Samsung Magician's advanced yet intuitive optimization tools; Monitor drive health, protect valuable data, and receive important updates for your 990 PRO
Measurement Reported result How to interpret it
Random point reads WiredTiger: 71K TPS under 16 client threads; RocksDB and the study’s B-tree variant: 57K TPS A result for the tested dataset, cache, hardware, software, and query definition
Random writes The study’s B-tree variant delivered 19% higher throughput than RocksDB and about 2.1× the throughput of WiredTiger Specific to the paper’s implementation and random-write workload

These measurements answer “what happened in this experiment,” not “which architecture always wins.” The comparison is discussed by the USENIX Association in Revisiting B+-tree vs. LSM-tree upon the Arrival of Modern Storage Hardware. Results can change with key distribution, value size, durability settings, thread count, cache pressure, compaction policy, and storage parallelism.

Compaction styles change the LSM tradeoff

Level-style compaction

In level-style compaction, files are organized into levels with increasing size. A file is merged with overlapping files in the next level, producing larger, more consolidated runs. RocksDB documents this style as optimizing disk footprint relative to the logical database size by merging a file with overlapping files at the next level.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • More consolidation usually lowers read and space amplification.
  • Repeated rewriting can increase write amplification.
  • Compaction needs sustained bandwidth and enough temporary headroom to create output files.

Universal-style compaction

Universal-style compaction groups sorted runs and merges them according to a different policy. RocksDB documentation describes it as typically lowering write amplification while raising read and space amplification compared with level style. It may also require more temporary space.

  • Lower rewrite pressure can suit heavy ingestion or devices where endurance and write bandwidth are limiting.
  • More overlapping runs can make reads and scans do more work.
  • Higher temporary and steady-state space use must be affordable during large merges.

Compaction style is therefore a configurable engineering choice, not an inherent property that all LSM deployments share. Defaults and controls can change between RocksDB versions, so verify the deployed version and configuration before applying tuning advice. The 2022 analysis Constructing and Analyzing the LSM Compaction Design Space examines how these choices move the read, write, and space-amplification balance.

Why modern hardware complicates the old rules

Traditional explanations often assume that random page writes are expensive and sequential file creation is cheap. SSDs, high parallelism, large memory, hardware compression, and fast CPUs weaken or change those assumptions. A B-tree may exploit fast random I/O and compression more effectively than an older rule of thumb suggests. An LSM may still win when batching and sequential writes keep compaction sustainable, but faster storage can also make compaction run more aggressively and expose CPU or space limits.

A peer-reviewed VLDB Endowment paper demonstrated how large the implementation effect can be: specialized B-tree techniques on a commercial storage drive with built-in transparent compression reduced measured B-tree write amplification by more than 10× in the paper’s tested setup. This is evidence that a B-tree can be redesigned for modern storage, not proof that ordinary B-trees universally outperform LSM-trees. See Closing the B-tree vs. LSM-tree Write Amplification Gap on Modern Storage Hardware with Built-in Transparent Compression.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose by workload, not by architecture slogan

1. Describe the write stream

  • Ingestion-heavy, append-like data: An LSM is a candidate because memtables and immutable files can batch many writes. Confirm that compaction can keep up at the target rate and that temporary space is available.
  • Random updates to existing keys: Compare the cost of rewriting B-tree pages with the LSM’s flush and compaction schedule. Update-heavy data can create many obsolete versions for compaction to remove.
  • Bursty or batched writes: Measure both foreground latency and the recovery period after a burst. A system that accepts a burst quickly but accumulates a compaction backlog may later throttle writes.

2. Classify the reads

  • Mostly point lookups: Evaluate cache hit rates, Bloom-filter effectiveness, tail latency, and behavior when the working set exceeds memory.
  • Many ordered or range scans: Give B-tree implementations serious consideration because their leaf ordering can reduce merge work. Benchmark the actual range widths and selectivity; a narrow lookup and a multi-million-row scan are different tests.
  • Mixed point and range traffic: Test foreground reads while compaction or index maintenance is active. Average throughput can hide unacceptable tail latency.

3. Relate the dataset to memory

If indexes, filters, and hot data fit comfortably in memory, either architecture may deliver low-latency reads. When the dataset is much larger than memory, cache misses, file overlap, tree height, and scan behavior become decisive. Measure with a cache state that represents production rather than only a warmed-up microbenchmark.

Best Value
WD_Black SN7100 1TB NVMe SSD - Gen4 PCIe, M.2 2280, Up to 7,250 MB/s Read Speed, Up to 6,900 MB/s Write Speed, Next Gen TLC 3D NAND, for Laptops, Handheld Gaming Devices - WDS100T4X0E
  • This product has been replaced by our latest generation. Please search for the SANDISK Optimus GX 7100 NVMe SSD
  • HIGH-OCTANE GAMING. Experience speeds up to 7,250MB/s read and 6,900MB/s write (1-2TB models), with up to 35% faster performance than previous generation.
  • PURPOSE-BUILT. Designed for serious on-the-go gamers, with a PCIe Gen4 interface and SANDISK’s next generation TLC 3D NAND.
  • MORE TIME TO CLEAR THAT CHECKPOINT. Built with laptops and handheld gaming devices in mind, with up to 100% more power efficiency over the previous generation.
  • DO MORE WITH DASHBOARD. Ensure your drive is optimized for prime performance with the downloadable WD_BLACK Dashboard (Windows only).

4. Account for the storage device

Record whether the device favors parallel reads, sequential writes, compression, or high endurance. Transparent compression can materially change B-tree write amplification, as the VLDB result illustrates. Fast storage does not eliminate LSM costs: it can shift the bottleneck to compaction CPU, write bandwidth, or temporary capacity.

5. Set latency and space objectives

Define a service-level target for median and tail latency, not just transactions per second. Decide how much compaction interference is acceptable, how much free space must remain for merges, and what write amplification the storage budget can sustain. An LSM configuration that maximizes ingestion may not meet a strict read-latency objective; a B-tree that delivers predictable scans may consume more write bandwidth under a random-update load.

6. Match the design to operational capacity

LSM deployments require visibility into compaction progress, pending work, write stalls, file counts, and space headroom. B-tree deployments require attention to page occupancy, split behavior, maintenance, checkpoints, and index growth. If the team cannot monitor and tune background work, prefer the architecture whose failure modes and defaults fit the workload without constant intervention.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to benchmark a consequential choice

  1. Use representative data. Match production key distribution, value sizes, update frequency, tombstones or deletes, and dataset-to-memory ratio.
  2. Replay the real mix. Separate random point reads, range scans, inserts, updates, and deletes, then test the expected mixture rather than one favorable operation.
  3. Measure warm and cold behavior. Record performance after caches warm and after restart or cache eviction. LSM file overlap and B-tree page locality can look very different in those states.
  4. Run long enough to reach steady state. Include the period when an LSM is compacting flushed data. Short tests can measure only memtable absorption and miss the later write cost.
  5. Capture tail latency and resource use. Track high-percentile read and write latency alongside throughput, CPU, device bandwidth, space consumption, and temporary compaction usage.
  6. Test overload and recovery. Increase ingestion until compaction backlog, write throttling, or page-maintenance pressure appears. Then measure how quickly the system returns to normal after the load drops.
  7. Pin versions and settings. Record database version, compaction style, durability options, cache sizes, thread counts, compression, and device configuration. Defaults can change, especially for LSM engines.

No broad, current cross-engine benchmark can predict every deployment. A representative benchmark is the only reliable way to decide when the architecture has meaningful consequences for cost or latency.

Common mistakes when comparing B-trees and LSM-trees

  • Comparing write throughput without compaction: An LSM can appear exceptionally fast until flushed files require sustained merging. Include steady-state compaction.
  • Using only point reads: This misses the extra merge work that range scans may impose on overlapping LSM levels.
  • Quoting amplification as a universal constant: Amplification depends on workload, levels, file sizes, compression, update patterns, and what the measurement counts.
  • Ignoring temporary space: Compaction may need room for output while old files remain live. A nearly full volume can turn a healthy design into an operational incident.
  • Assuming a named engine represents its whole architecture: RocksDB settings, B-tree variants, storage hardware, and software versions all affect results.
  • Optimizing average throughput while missing tail latency: Background work can cause pauses or stalls that averages conceal.
  • Applying old hardware assumptions: Fast parallel storage and transparent compression can alter the relative costs enough to invalidate a textbook conclusion.

A practical decision framework

Start with the workload’s dominant risk. If sustained ingestion is the primary requirement, an LSM is attractive when compaction bandwidth, CPU, and space headroom are demonstrably sufficient. If ordered scans and predictable navigation dominate, a B-tree is a strong candidate, especially when the working set or index locality supports cache-efficient leaf traversal. For a mixed workload, compare both under production-like concurrency and compaction or maintenance activity.

Then verify the decision against four constraints: the dataset’s size relative to memory, the storage device’s actual behavior, the required tail-latency envelope, and the team’s ability to operate the background work. Revisit the choice when any of those constraints changes. The storage-engine tradeoff is not “fast writes versus fast reads” in the abstract; it is where your system spends its I/O, CPU, memory, and operational attention for the specific queries and updates it must serve.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.