B-tree (overview)
- In a B-tree, every node (including internal nodes) can store actual keys along with their record pointers (row numbers).
- Example from this dataset: the root contains keys Leo (row 2) and Raj (row 8).
- Keys less than Leo belong to the first child block (Ava, Ben). Keys between Leo and Raj go to the second child block (Maya, Nina, Omar). Keys greater than Raj go to the third child block (Sarah, Tom).
- Each key appears exactly once somewhere in the tree — either in an internal node or in a leaf.
In a B-tree, internal nodes can store full data pointers. That means some lookups can terminate earlier if the sought key is present in an internal node.
B+ tree (overview)
- In a B+ tree, internal nodes act only as signposts: they store keys to guide searches and pointers to child nodes, but they do not store record pointers themselves.
- All actual records (names + row numbers) are stored in the leaf blocks. For our example the leaves contain: [Ava, Ben, Leo], [Maya, Nina, Omar], and [Raj, Sarah, Tom].
- All leaf blocks are linked together by sibling pointers (a doubly- or singly-linked list across leaves), enabling very efficient ordered traversal.
Key comparison
Searching for a key (example: Leo)
- B-tree: Leo is stored in the root (row 2), so the search can stop at the root — one node read.
- B+ tree: The root only guides the search to the correct leaf. You must descend and read the leaf containing Leo — two node reads. For this particular lookup the B-tree appears faster.
Why B+ trees usually win in practice
- Higher branching factor: Internal nodes store only keys (no record pointers), allowing more keys per node. This shortens the tree height and reduces disk seeks for lookups.
- Efficient range and sequential scans: Linked leaf nodes let a query descend once to the starting leaf and then read contiguous leaf blocks in order, without repeated traversals.
- Better disk I/O characteristics: More keys per internal node means fewer node reads for long paths; leaf linkage means scans read sequential disk pages, which is faster on spinning disks and still advantageous for SSDs due to locality.
Example: range query Ben to Maya
- B+ tree:
- Descend to the leaf containing Ben.
- Read Ben and Leo from that leaf.
- Follow the sibling pointer to the next leaf and read Maya.
- Result: one downward descent + sequential leaf reads.
- B-tree:
- Ben may be in a leaf, Leo could be stored in an internal node, and Maya in another leaf. The DBMS may have to jump between internal nodes and leaves repeatedly, moving up and down the tree — more node reads and random access as the tree grows.

Practical notes and references
- Mental model: a B-tree may store data in internal nodes as well as leaves; a B+ tree keeps all data in the leaves and links those leaves together for efficient ordered traversal.
- When database engines such as PostgreSQL or MySQL say they use a “B-tree” index, they commonly mean an implementation equivalent to a B+ tree — optimized for disk access patterns, large datasets, and efficient range queries.
- For deeper reading:
- B+ tree overview: https://en.wikipedia.org/wiki/B%2B_tree
- B-tree overview: https://en.wikipedia.org/wiki/B-tree
Databases typically prefer the B+ tree structure because leaf-only record storage, linked leaves, and a higher branching factor combine to minimize disk reads and make range queries faster.