Chapter 3: Storage and Retrieval Engines

Log-Structured vs Page-Oriented Storage

How does a database store the data that you give it, and how does it find it again when you ask for it?

hljs language-sql
-- Simple indexing with B-Trees vs LSM-Trees
SELECT * FROM events WHERE timestamp >= '2026-01-01' ORDER BY timestamp ASC;
  • LSM-Trees (Log-Structured Merge-Trees): Optimized for high write throughput. Used in RocksDB, Cassandra.
  • B-Trees: Optimized for fast reads and random access. Standard in PostgreSQL, MySQL.