How Databases Store Data: B-Trees vs LSM Trees Explained

Added:

Disk I/O Basics
B-Tree Basics
B-Tree Writes
LSM Tree Writes
LSM Reads
Choosing Engine

Disk I/O Basics

0:00
Playing Section
  • 1

    Highlights the massive speed gap between memory and disk access.

  • 2

    Explains why minimizing random disk reads is crucial for database performance.

Fundamental tree data structures, such as Binary Search Trees (BSTs) and self-balancing trees.
The physical differences between memory (RAM) and disk storage, specifically regarding sequential vs. random I/O operations.
Basic database concepts, including what a database index is and why it is used to optimize search queries.
Time complexity analysis (Big O notation) to evaluate search, insertion, and deletion efficiency.
Real-world application of these engines, comparing B-Tree-based databases (e.g., PostgreSQL, MySQL) with LSM-Tree-based databases (e.g., Apache Cassandra, RocksDB).
LSM-Tree optimization mechanisms, such as Bloom filters (to reduce read amplification) and compaction strategies (Leveled vs. Size-Tiered compaction).
Write-Ahead Logging (WAL) and crash recovery techniques used by storage engines to ensure ACID durability.
Concurrency control protocols, such as Multi-Version Concurrency Control (MVCC), and how they are implemented at the storage engine level.
28.8K views1.4Klikes11:22@ByteMonkOriginal Release: 2025-12-26

Databases store data using two fundamental approaches: B-Trees (used in PostgreSQL, MySQL, SQLite) which organize data in a balanced tree structure for fast random reads and range queries, and LSM Trees (used in Cassandra, RocksDB, NoSQL databases) which prioritize write efficiency by appending data sequentially to memory and disk, then periodically merging and compacting files; the choice between these approaches depends on whether the workload is read-heavy (B-Trees) or write-heavy (LSM Trees).