mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user