|
6 | 6 | * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 |
| - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.84 2007/02/13 02:31:02 tgl Exp $ |
| 9 | + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.85 2007/02/16 00:14:01 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
@@ -253,52 +253,14 @@ static bool
|
253 | 253 | desirable_join(PlannerInfo *root,
|
254 | 254 | RelOptInfo *outer_rel, RelOptInfo *inner_rel)
|
255 | 255 | {
|
256 |
| - ListCell *l; |
257 |
| - |
258 | 256 | /*
|
259 |
| - * Join if there is an applicable join clause. |
| 257 | + * Join if there is an applicable join clause, or if there is a join |
| 258 | + * order restriction forcing these rels to be joined. |
260 | 259 | */
|
261 |
| - if (have_relevant_joinclause(root, outer_rel, inner_rel)) |
| 260 | + if (have_relevant_joinclause(root, outer_rel, inner_rel) || |
| 261 | + have_join_order_restriction(root, outer_rel, inner_rel)) |
262 | 262 | return true;
|
263 | 263 |
|
264 |
| - /* |
265 |
| - * Join if the rels overlap the same outer-join side and don't already |
266 |
| - * implement the outer join. This is needed to ensure that we can find a |
267 |
| - * valid solution in a case where an OJ contains a clauseless join. |
268 |
| - */ |
269 |
| - foreach(l, root->oj_info_list) |
270 |
| - { |
271 |
| - OuterJoinInfo *ojinfo = (OuterJoinInfo *) lfirst(l); |
272 |
| - |
273 |
| - /* ignore full joins --- other mechanisms preserve their ordering */ |
274 |
| - if (ojinfo->is_full_join) |
275 |
| - continue; |
276 |
| - if (bms_overlap(outer_rel->relids, ojinfo->min_righthand) && |
277 |
| - bms_overlap(inner_rel->relids, ojinfo->min_righthand) && |
278 |
| - !bms_overlap(outer_rel->relids, ojinfo->min_lefthand) && |
279 |
| - !bms_overlap(inner_rel->relids, ojinfo->min_lefthand)) |
280 |
| - return true; |
281 |
| - if (bms_overlap(outer_rel->relids, ojinfo->min_lefthand) && |
282 |
| - bms_overlap(inner_rel->relids, ojinfo->min_lefthand) && |
283 |
| - !bms_overlap(outer_rel->relids, ojinfo->min_righthand) && |
284 |
| - !bms_overlap(inner_rel->relids, ojinfo->min_righthand)) |
285 |
| - return true; |
286 |
| - } |
287 |
| - |
288 |
| - /* |
289 |
| - * Join if the rels are members of the same IN sub-select. This is needed |
290 |
| - * to ensure that we can find a valid solution in a case where an IN |
291 |
| - * sub-select has a clauseless join. |
292 |
| - */ |
293 |
| - foreach(l, root->in_info_list) |
294 |
| - { |
295 |
| - InClauseInfo *ininfo = (InClauseInfo *) lfirst(l); |
296 |
| - |
297 |
| - if (bms_is_subset(outer_rel->relids, ininfo->righthand) && |
298 |
| - bms_is_subset(inner_rel->relids, ininfo->righthand)) |
299 |
| - return true; |
300 |
| - } |
301 |
| - |
302 | 264 | /* Otherwise postpone the join till later. */
|
303 | 265 | return false;
|
304 | 266 | }
|
0 commit comments