Subquery decorrelation
The correlated SubPlan re-executes 30,411 times under PG. ORCA rewrites it into a single HashAggregate that runs once.
Same query. Same data. Same PostgreSQL 18 binary. The only thing that changes is SET pg_orca.enable_orca. Vanilla planner: 10,066 ms. ORCA: 308 ms.
Scale factor 5 · 30M lineitem rows · 1M part rows · single-node, no parallelism · 3-run median EXPLAIN ANALYZE.
The correlated SubPlan re-executes 30,411 times under PG. ORCA rewrites it into a single HashAggregate that runs once.
PG settles for a Hash Join with a re-executed inner aggregate. ORCA evaluates bushy variants and picks a nested-loop ladder over the pre-aggregated side.
The vanilla plan touches 1.6M shared buffers. The ORCA plan reads 87K — pruning falls out of the better join order, not from new indexes.