The Lost Art of High-Performance PostgreSQL: Index Tuning & Query Optimization
Understanding Query Execution Plans
Before optimizing any query, run EXPLAIN (ANALYZE, BUFFERS, VERBOSE). Pay attention to shared hit vs read blocks, heap fetches, and whether index scans are bitmap or index-only scans.


