Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cd2a2ce

Browse files
committed
Change have_join_order_restriction() so that we do not force a clauseless join
if either of the input relations can legally be joined to any other rels using join clauses. This avoids uselessly (and expensively) considering a lot of really stupid join paths when there is a join restriction with a large footprint, that is, lots of relations inside its LHS or RHS. My patch of 15-Feb-2007 had been causing the code to consider joining *every* combination of rels inside such a group, which is exponentially bad :-(. With this behavior, clauseless bushy joins will be done if necessary, but they'll be put off as long as possible. Per report from Jakub Ouhrabka. Backpatch to 8.2. We might someday want to backpatch to 8.1 as well, but 8.1 does not have the problem for OUTER JOIN nests, only for IN-clauses, so it's not clear anyone's very likely to hit it in practice; and the current patch doesn't apply cleanly to 8.1.
1 parent 462227d commit cd2a2ce

File tree

2 files changed

+180
-63
lines changed

2 files changed

+180
-63
lines changed

src/backend/optimizer/README

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ than applying a sort to the cheapest other path).
174174
If the query contains one-sided outer joins (LEFT or RIGHT joins), or
175175
"IN (sub-select)" WHERE clauses that were converted to joins, then some of
176176
the possible join orders may be illegal. These are excluded by having
177-
make_join_rel consult side lists of outer joins and IN joins to see
177+
join_is_legal consult side lists of outer joins and IN joins to see
178178
whether a proposed join is illegal. (The same consultation allows it
179179
to see which join style should be applied for a valid join, ie,
180180
JOIN_INNER, JOIN_LEFT, etc.)
@@ -217,7 +217,7 @@ FULL JOIN ordering is enforced by not collapsing FULL JOIN nodes when
217217
translating the jointree to "joinlist" representation. LEFT and RIGHT
218218
JOIN nodes are normally collapsed so that they participate fully in the
219219
join order search. To avoid generating illegal join orders, the planner
220-
creates an OuterJoinInfo node for each outer join, and make_join_rel
220+
creates an OuterJoinInfo node for each outer join, and join_is_legal
221221
checks this list to decide if a proposed join is legal.
222222

223223
What we store in OuterJoinInfo nodes are the minimum sets of Relids
@@ -226,7 +226,7 @@ these are minimums; there's no explicit maximum, since joining other
226226
rels to the OJ's syntactic rels may be legal. Per identities 1 and 2,
227227
non-FULL joins can be freely associated into the lefthand side of an
228228
OJ, but in general they can't be associated into the righthand side.
229-
So the restriction enforced by make_join_rel is that a proposed join
229+
So the restriction enforced by join_is_legal is that a proposed join
230230
can't join a rel within or partly within an RHS boundary to one outside
231231
the boundary, unless the join validly implements some outer join.
232232
(To support use of identity 3, we have to allow cases where an apparent

0 commit comments

Comments
 (0)