Skip to content

Commit 953208a

Browse files
committed
In a nestloop inner indexscan, it's OK to use pushed-down baserestrictinfo
clauses even if it's an outer join. This is a corner case since such clauses could only arise from weird OUTER JOIN ON conditions, but worth fixing. Per example from Ron at cheapcomplexdevices.com.
1 parent 974c5a8 commit 953208a

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

src/backend/optimizer/path/indxpath.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.195 2005/11/30 17:10:19 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.196 2005/12/06 16:50:36 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1357,50 +1357,40 @@ find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel,
13571357
Relids outer_relids, bool isouterjoin)
13581358
{
13591359
List *clause_list = NIL;
1360-
bool jfound = false;
13611360
Relids join_relids;
13621361
ListCell *l;
13631362

1364-
/*
1365-
* We can always use plain restriction clauses for the rel. We scan these
1366-
* first because we want them first in the clause list for the convenience
1367-
* of remove_redundant_join_clauses, which can never remove non-join
1368-
* clauses and hence won't be able to get rid of a non-join clause if it
1369-
* appears after a join clause it is redundant with.
1370-
*/
1371-
foreach(l, rel->baserestrictinfo)
1372-
{
1373-
RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
1374-
1375-
/* Can't use pushed-down clauses in outer join */
1376-
if (isouterjoin && rinfo->is_pushed_down)
1377-
continue;
1378-
clause_list = lappend(clause_list, rinfo);
1379-
}
1380-
13811363
/* Look for joinclauses that are usable with given outer_relids */
13821364
join_relids = bms_union(rel->relids, outer_relids);
13831365

13841366
foreach(l, rel->joininfo)
13851367
{
13861368
RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
13871369

1388-
/* Can't use pushed-down clauses in outer join */
1370+
/* Can't use pushed-down join clauses in outer join */
13891371
if (isouterjoin && rinfo->is_pushed_down)
13901372
continue;
13911373
if (!bms_is_subset(rinfo->required_relids, join_relids))
13921374
continue;
13931375

13941376
clause_list = lappend(clause_list, rinfo);
1395-
jfound = true;
13961377
}
13971378

13981379
bms_free(join_relids);
13991380

14001381
/* if no join clause was matched then forget it, per comments above */
1401-
if (!jfound)
1382+
if (clause_list == NIL)
14021383
return NIL;
14031384

1385+
/*
1386+
* We can also use any plain restriction clauses for the rel. We put
1387+
* these at the front of the clause list for the convenience of
1388+
* remove_redundant_join_clauses, which can never remove non-join clauses
1389+
* and hence won't be able to get rid of a non-join clause if it appears
1390+
* after a join clause it is redundant with.
1391+
*/
1392+
clause_list = list_concat(list_copy(rel->baserestrictinfo), clause_list);
1393+
14041394
/*
14051395
* We may now have clauses that are known redundant. Get rid of 'em.
14061396
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy