Skip to content
Commitwise
Menu

B-tree

Also called: B+ tree, Btree index

The sorted, shallow tree most database indexes use, so a lookup reads a few pages even in a huge table.

Definition

Each page holds many sorted keys and points to hundreds of child pages, so a tree over hundreds of millions of rows is only 3 or 4 levels deep. Leaf pages are linked in order, which makes range queries and ORDER BY cheap. A multi-column B-tree is sorted by the first column, then the second, so it serves queries on its leftmost columns.

In practice

An index on orders (customer_id, created_at) finds customer 42's ten newest orders by reading about four pages.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.