Listen

Description

n this episode, we dive into the B-tree, the de facto standard for organizing file indexes and database systems. When a file's keys are too large to fit in main memory, systems must rely on an external index, where the time spent accessing secondary storage dominates total processing time.

The central insight of the B-tree is its ability to stay strictly balanced by keeping all leaves at the same depth, so that even a file of one million records can be searched in at most four disk accesses in the worst case. We unpack how B-trees maintain this balance dynamically through node splitting on insertion and redistribution or concatenation on deletion, keeping structural changes localized to a single path and eliminating the need for massive periodic file reorganizations.

Finally, we explore how locking protocols handle multiuser concurrency and how IBM had successfully put B-trees to work in a real-world access method in VSAM.

If you've ever wondered why databases can handle millions of random and sequential queries without grinding to a halt, this episode will make those behaviors finally make sense.

Modern systems choose structures by workload, such as LSM-trees (RocksDB, Cassandra) for write-heavy workloads and Tries/Radix trees for prefix search.

References:

The Ubiquitous B-Tree by DOUGLAS COMER.

https://dl.acm.org/doi/10.1145/356770.356776