Hacking the Query Planner, Again
summary
Explains exact planner actions: four phases (preprocess, scan/join plan, post-scan, postprocess) and concrete rewrites like ANY/EXISTS → semi-joins, inlining SQL functions, flattening subselects, and reducing outer joins to inner or anti-joins without using statistics. Shows how quals get distributed with equivalence classes and how join-order legality is enforced. Join search uses dynamic programming, falls back to genetic optimizer fallback past 12 relations, and honors a join-collapse limit (default 4); cost estimates drive choosing hash/merge/nested-loop and avoiding unnecessary final sorts.
AI-written summary · about
