Part 139: Database Statistics & The Query Cost Optimizer
The optimizer relies on statistical histograms to estimate how many rows match a filter.
1. Updating Statistics with ANALYZE
If a table undergoes massive inserts or deletions, outdated statistics can trick the optimizer into choosing terrible execution plans:
-- Refresh statistics table for optimizer:
ANALYZE users;
Key Takeaways
- Keep database table statistics fresh with automated autovacuum and
ANALYZE.
In Part 140, we explore Index Maintenance: Rebuilding & Monitoring Unused Indexes!

