diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-04-05 16:59:00 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-04-05 16:59:09 -0400 |
commit | 16dc2703c5413534d4989e08253e8f4fcb0e2aab (patch) | |
tree | c25f739d183d93510418b734ebd36fc3e2e9fde9 /src/backend/optimizer/path/pathkeys.c | |
parent | dad50f677c42de207168a3f08982ba23c9fc6720 (diff) |
Support "Right Anti Join" plan shapes.
Merge and hash joins can support antijoin with the non-nullable input
on the right, using very simple combinations of their existing logic
for right join and anti join. This gives the planner more freedom
about how to order the join. It's particularly useful for hash join,
since we may now have the option to hash the smaller table instead
of the larger.
Richard Guo, reviewed by Ronan Dunklau and myself
Discussion: https://postgr.es/m/CAMbWs48xh9hMzXzSy3VaPzGAz+fkxXXTUbCLohX1_L8THFRm2Q@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/path/pathkeys.c')
-rw-r--r-- | src/backend/optimizer/path/pathkeys.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index c4e7f97f687..e53ea842248 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -1077,9 +1077,9 @@ find_var_for_subquery_tle(RelOptInfo *rel, TargetEntry *tle) * Build the path keys for a join relation constructed by mergejoin or * nestloop join. This is normally the same as the outer path's keys. * - * EXCEPTION: in a FULL or RIGHT join, we cannot treat the result as - * having the outer path's path keys, because null lefthand rows may be - * inserted at random points. It must be treated as unsorted. + * EXCEPTION: in a FULL, RIGHT or RIGHT_ANTI join, we cannot treat the + * result as having the outer path's path keys, because null lefthand rows + * may be inserted at random points. It must be treated as unsorted. * * We truncate away any pathkeys that are uninteresting for higher joins. * @@ -1095,7 +1095,9 @@ build_join_pathkeys(PlannerInfo *root, JoinType jointype, List *outer_pathkeys) { - if (jointype == JOIN_FULL || jointype == JOIN_RIGHT) + if (jointype == JOIN_FULL || + jointype == JOIN_RIGHT || + jointype == JOIN_RIGHT_ANTI) return NIL; /* |