Database Internals Book Notes by Verity Chu, 10 Feb, 2022

discuss some concepts specific to B-Trees.

  1. organization: how to establish relationships between keys and pointers, and how to implement headers and links between pages.
  2. processes that occur during root-to-leaf descends: how to perform binary search how to collect breadcrumbs and keep track of parent nodes ( in case we later have to split or merge nodes.)
  3. optimization techniques (rebalancing, right-only appends, and bulk loading), maintenance processes, and garbage collection.

Page Header

holds information about the page that can be used for navigation, maintenance, and optimizations.

usually contains flags: that describe page contents and layout, number of cells in the page, lower and upper offsets marking the empty space (used to append cell offsets and data), and other useful metadata.

e.g.

Screen Shot 2022-02-10 at 8.08.48 am.png

Postgres: page size, layout version

Screen Shot 2022-02-10 at 8.06.25 am.png

Screen Shot 2022-02-10 at 8.09.25 am.png

MySQL InnoDB: number of heap records, level, some implementation-specific values.

Screen Shot 2022-02-10 at 8.10.19 am.png

SQLite: number of cells and a rightmost pointer.

Screen Shot 2022-02-10 at 8.11.00 am.png

Screen Shot 2022-02-10 at 8.12.04 am.png

Magic numbers

often placed in the file or page header often used for validation and sanity checks Usually, it’s a multibyte block, containing a constant value that can be used to signal that the block represents a page, specify its kind, or identify its version.