PostgreSQL Query Tuning: A Foundation Every Database Developer Should Build
summary
Shows how to find slow SQL with pg_stat_statements and capture plans automatically with auto_explain, then read EXPLAIN ANALYZE outputs in the context of real metadata: default stats target 300 (max 30,000 samples), vacuum visibility, partial indexes, and when partition pruning fails because functions are volatile. Demonstrates practical fixes — increase column statistics, add correlated statistics, avoid casting and CTE materialization, tune work_mem/hash settings and max_parallel_workers_per_gather — and ships an open source HTML inspector called pgtx_plan to combine plan plus object definitions.
AI-written summary · about
chapters (8)
- 0:00Introduction to query tuning
- 3:59Finding problematic queries
- 8:14Analyzing query execution plans
- 14:32Understanding statistics and metadata
- 21:31DDL and schema design impact
- 25:45Query rewrite and planner empathy
- 31:02Parameter settings and timeouts
- 33:30Open-source tool for tuning
related talks
23mBest Practices for Tuning Slow Postgres Queries
52mUnderstanding PostgreSQL Query Plans (aka EXPLAIN)
41mOptimizing your app by understanding your PostgreSQL database
47mIdentifying Slow Queries and Fixing Them!
24mTop 5 PostgreSQL Query Tuning Tips
26mBe Good Friends with Query Planner
45mMake Your SQL Queries 10,000x Faster, for Good
50mPostgreSQL Query Performance Insights
