Skip to content

Commit 3f36070

Browse files
committed
Fix adjust_semi_join to be more cautious about clauseless joins.
It was reporting that these were fully indexed (hence cheap), when of course they're the exact opposite of that. I'm not certain if the case would arise in practice, since a clauseless semijoin is hard to produce in SQL, but if it did happen we'd make some dumb decisions.
1 parent 368e44f commit 3f36070

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/backend/optimizer/path/costsize.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,12 +2810,20 @@ adjust_semi_join(PlannerInfo *root, JoinPath *path, SpecialJoinInfo *sjinfo,
28102810
*/
28112811
if (indexed_join_quals)
28122812
{
2813-
List *nrclauses;
2813+
if (path->joinrestrictinfo != NIL)
2814+
{
2815+
List *nrclauses;
28142816

2815-
nrclauses = select_nonredundant_join_clauses(root,
2816-
path->joinrestrictinfo,
2817-
path->innerjoinpath);
2818-
*indexed_join_quals = (nrclauses == NIL);
2817+
nrclauses = select_nonredundant_join_clauses(root,
2818+
path->joinrestrictinfo,
2819+
path->innerjoinpath);
2820+
*indexed_join_quals = (nrclauses == NIL);
2821+
}
2822+
else
2823+
{
2824+
/* a clauseless join does NOT qualify */
2825+
*indexed_join_quals = false;
2826+
}
28192827
}
28202828

28212829
return true;

0 commit comments

Comments
 (0)