Beyond the Basics: Mastering PostgreSQL Index Performance
summary
Benchmarks show a text btree index costs 2.5 GB and slows inserts sixfold, while an integer primary key index is 214 MB and keeps inserts near baseline; creating a text index cuts a query from 665 ms to 1 ms but rebuilds cost 37 s and block writes; GIN trigram index builds in 2m33s using ~1 GB and can make LIKE/ILIKE slower; vacuum requires two runs to reclaim index pages, and reindex blocks writes for ~37s, so choose index type, column order and memory fit carefully.
AI-written summary · about
chapters (13)
- 0:00Introduction and speaker intro
- 3:08What is a database index
- 8:05PostgreSQL index structure deep dive
- 12:47Index bloat causes and effects
- 15:18Benchmark environment setup
- 18:12Sequential scan vs indexed scan
- 20:19Impact of excessive indices
- 22:50Redundant and composite indices
- 25:45LIKE operator and text indexing
- 27:30pg_trgm and advanced indexing
- 29:15GiST and GIN index performance
- 30:58TOAST and large text fields
- 31:42Performance rules and wrap-up
