Ch. 3
Data Structures That Power Your Database
Under every database API lies a storage engine choosing between log-structured and B-tree designs.
Storage engines are the library components that databases use to store and retrieve bytes on disk. The two dominant families are log-structured merge (LSM) trees and B-trees — each optimizing for different workloads.
LSM-Trees vs B-Trees
B-trees update pages in place — predictable read latency, but random writes can be slow on spinning disks. LSM-trees append writes to a log, then compact sorted segments — excellent write throughput at the cost of occasional read amplification during compaction.
LSM-treeB-treeRocksDBPostgreSQLSSTablestorage enginecompaction