PostgreSQL & Databases
B tree indexes
A B-tree is the default index type, a sorted tree that serves equality, ranges and ordering. You learn how to test an index with EXPLAIN ANALYZE and check whether it is used.
What you will be able to do
- Explain why a B-tree index serves equality, range and ORDER BY queries.
- Decide whether a new index is worth its write cost, using plans and usage statistics.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in PostgreSQL & Databases
- Isolation anomaliesIntermediate · 4 min
An isolation level decides which concurrent changes a transaction can see, and which anomalies remain. You learn the four classic anomalies and how PostgreSQL's three…
- Deadlock detectionIntermediate · 4 min
A deadlock is a cycle of lock waits, and PostgreSQL aborts one transaction in the cycle after deadlock_timeout. You learn how to find the blocker, and how lock ordering…
- Composite index orderingIntermediate · 4 min
A composite index sorts by its first column, then by its second, so column order decides which queries it helps. You learn to order columns from the queries that…
- Index only scansIntermediate · 4 min
An index-only scan answers from the index, but it still visits the heap for pages the visibility map has not marked all-visible. You learn to read Heap Fetches, and…
- EXPLAIN ANALYZE BUFFERSAdvanced · 4 min
EXPLAIN ANALYZE with BUFFERS shows how many pages each plan node reads from cache and from outside it. You learn to read the hit, read and temp counts before judging a…
- Planner statisticsAdvanced · 4 min
Planner statistics are sampled estimates that ANALYZE stores per column, and the planner uses them to pick plans. You learn to compare estimates with real counts and to…