DatabasesIndexingB+ Tree

B-Tree vs LSM-Tree Indexing

Understand the indexing structures behind relational SQL databases and write-heavy NoSQL databases.

Abstract Algorithms

Abstract Algorithms

Jul 2, 2026Β·1 min readΒ·Intermediate
⚑

Quick Take

Database engines rely on specialized index structures to speed up reads, but choose different architectures depending on read vs write ratios. πŸ“Š B-Tree Index (Read-Optimized) Used in relational datab

Database engines rely on specialized index structures to speed up reads, but choose different architectures depending on read vs write ratios.

πŸ“Š B-Tree Index (Read-Optimized)

Used in relational databases like PostgreSQL, MySQL, and SQLite.

  • Structure: A self-balancing search tree mapping sorted data pages.
  • Trade-off: Fast O(log N) random reads and writes, but updates require random disk I/O.
                  [ Root Node ]
                 /      |      \
         [ Internal ] [ Internal ] [ Internal ]
          /    |   \    /   |   \    /   |   \
        [Leaf][Leaf][Leaf]... Page Data (On Disk)

πŸ“Š LSM-Tree Index (Write-Optimized)

Used in NoSQL databases like Cassandra, RocksDB, and DynamoDB.

  • Structure: Append-only writes to an in-memory buffer (MemTable), which are flushed periodically to sorted, immutable on-disk files (SSTables).
  • Trade-off: Blazing fast write throughput, but reads are slower due to compaction and checking multiple files.

AI-generated article quiz

Test your understanding

🧠

Ready to test what you just learned?

Generate four focused questions from this article. Answers include immediate explanations.

Reader feedback

Was this article useful?

Rate it if it helped, then continue with the next deep dive when you are ready.

Sign in to save your rating.