Extending Extended Statistics to Joins
summary
Proof-of-concept PostgreSQL patch extends CREATE STATISTICS to collect join-level MCV for two-way equality inner joins, adds STX_rowid/STX_keys_refs/STX_join_rows catalog fields, and implements index-probe sampling by sampling an anchor table and probing indexes on the other side. On the IMDB join-order benchmark (32 affected queries) cardinality estimates improve and total execution time drops about 1.3–1.5x with the slowest queries showing dramatic wins; ANALYZE cost rises ~200 ms. Current limits: anchor-table-triggered ANALYZE, requires an index, no composite-index probing yet.
AI-written summary · about
chapters (14)
- 0:00Introduction to join statistics
- 1:06Problem with planner independence assumption
- 2:53Quantifying the problem scope
- 5:21Ongoing discussion on join stats
- 7:05Current syntax and catalog design
- 8:30Stats collection implementation
- 9:55Stats matching and predicate handling
- 10:59Benchmark results with join stats
- 12:25Alternative syntax and design choices
- 13:08Stats collection for unindexed joins
- 13:49Supporting N-way joins
- 14:09Query exploitation challenges
- 15:33Potential global plan impact
- 16:16Summary and next steps
