Lesson 3 of 12

B-Tree Indexes: Structure and When They Win

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source

The one thing to understand first

A B-tree is the default and most versatile PostgreSQL index, implemented in src/backend/access/nbtree/. It supports equality and range operators (=, <, <=, >, >=, BETWEEN, IN), ORDER BY acceleration, and uniqueness enforcement — all from one balanced, ordered structure.

A B-tree wins because it keeps your keys sorted — and almost everything useful (selective equality, ranges, ORDER BY, uniqueness) is just a consequence of sorted order. Understand that, plus the leftmost-prefix rule for composite indexes, and most “why isn’t my index used” questions answer themselves.

Structure: a balanced ordered tree

PostgreSQL implements a Lehman-Yao B-tree variant designed for high concurrency. The tree has:

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • High concurrency by design
  • When a B-tree wins
  • Column order in composite indexes
  • Index-only scans
  • Layer 3 — Watch it happen on your own database
  • Layer 4 — The levers this hands you
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Was this helpful?

← Back to 02 — Performance: Query & Index Mastery