Get rid of the planner's LateralJoinInfo data structure.
Tom Lane <tgl@sss.pgh.pa.us>
Get rid of the planner's LateralJoinInfo data structure. I originally modeled this data structure on SpecialJoinInfo, but after commit acfcd45cacb6df23 that looks like a pretty poor decision. All we really need is relid sets identifying laterally-referenced rels; and most of the time, what we want to know about includes indirect lateral references, a case the LateralJoinInfo data was unsuited to compute with any efficiency. The previous commit redefined RelOptInfo.lateral_relids as the transitive closure of lateral references, so that it easily supports checking indirect references. For the places where we really do want just direct references, add a new RelOptInfo field direct_lateral_relids, which is easily set up as a copy of lateral_relids before we perform the transitive closure calculation. Then we can just drop lateral_info_list and LateralJoinInfo and the supporting code. This makes the planner's handling of lateral references noticeably more efficient, and shorter too. Such a change can't be back-patched into stable branches for fear of breaking extensions that might be looking at the planner's data structures; but it seems not too late to push it into 9.5, so I've done so.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/nodes/copyfuncs.c | modified | +0 −17 |
| src/backend/nodes/equalfuncs.c | modified | +0 −12 |
| src/backend/nodes/outfuncs.c | modified | +1 −13 |
| src/backend/optimizer/path/joinrels.c | modified | +6 −30 |
| src/backend/optimizer/plan/analyzejoins.c | modified | +0 −3 |
| src/backend/optimizer/plan/initsplan.c | modified | +55 −107 |
| src/backend/optimizer/plan/planagg.c | modified | +1 −2 |
| src/backend/optimizer/plan/planmain.c | modified | +2 −4 |
| src/backend/optimizer/plan/planner.c | modified | +1 −2 |
| src/backend/optimizer/prep/prepjointree.c | modified | +2 −7 |
| src/backend/optimizer/prep/prepunion.c | modified | +0 −1 |
| src/backend/optimizer/util/placeholder.c | modified | +13 −47 |
| src/backend/optimizer/util/relnode.c | modified | +17 −0 |
| src/backend/optimizer/util/var.c | modified | +0 −1 |
| src/backend/rewrite/rewriteManip.c | modified | +0 −3 |
| src/include/nodes/nodes.h | modified | +0 −1 |
| src/include/nodes/relation.h | modified | +2 −39 |