Module 2 · Indexes
Episode 18 Lab: The Index That Wasn't Used
▶ This video is coming to YouTube soon.
Four queries on a real Postgres store ignore their indexes. This lab reproduces each with EXPLAIN (ANALYZE, BUFFERS), diagnoses why (a composite index's leading column, a function on the column, a numeric cast, and a predicate matching 29.9% of rows), fixes three of them, and measures why forcing the fourth is slower.
Chapters
- 0:00Intro
- 0:13The symptom
- 0:31Reproduce: four queries, four Seq Scans
- 1:09Diagnose A: the index leads with the wrong column
- 2:01Diagnose B and C: the index holds the column, not your expression
- 2:53Diagnose D: 30% of the rows is every page
- 3:42Fix A, B and C
- 4:17Measure D: forcing the index is slower
- 5:12Before and after
- 5:45Why isn't my index used? A checklist
- 6:29Recap
- 6:55Next: Processing Models