summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/prep/prepjointree.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-04-05 16:59:00 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-04-05 16:59:09 -0400
commit16dc2703c5413534d4989e08253e8f4fcb0e2aab (patch)
treec25f739d183d93510418b734ebd36fc3e2e9fde9 /src/backend/optimizer/prep/prepjointree.c
parentdad50f677c42de207168a3f08982ba23c9fc6720 (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/prep/prepjointree.c')
-rw-r--r--src/backend/optimizer/prep/prepjointree.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c
index 870d84b29d7..2f589b1b99f 100644
--- a/src/backend/optimizer/prep/prepjointree.c
+++ b/src/backend/optimizer/prep/prepjointree.c
@@ -406,8 +406,8 @@ pull_up_sublinks_jointree_recurse(PlannerInfo *root, Node *jtnode,
* point of the available_rels machinations is to ensure that we only
* pull up quals for which that's okay.
*
- * We don't expect to see any pre-existing JOIN_SEMI or JOIN_ANTI
- * nodes here.
+ * We don't expect to see any pre-existing JOIN_SEMI, JOIN_ANTI, or
+ * JOIN_RIGHT_ANTI jointypes here.
*/
switch (j->jointype)
{
@@ -2640,9 +2640,10 @@ flatten_simple_union_all(PlannerInfo *root)
* distribute_qual_to_rels to get rid of such clauses.
*
* Also, we get rid of JOIN_RIGHT cases by flipping them around to become
- * JOIN_LEFT. This saves some code here and in some later planner routines,
- * but the main reason to do it is to not need to invent a JOIN_REVERSE_ANTI
- * join type.
+ * JOIN_LEFT. This saves some code here and in some later planner routines;
+ * the main benefit is to reduce the number of jointypes that can appear in
+ * SpecialJoinInfo nodes. Note that we can still generate Paths and Plans
+ * that use JOIN_RIGHT (or JOIN_RIGHT_ANTI) by switching the inputs again.
*
* To ease recognition of strict qual clauses, we require this routine to be
* run after expression preprocessing (i.e., qual canonicalization and JOIN
@@ -2896,7 +2897,8 @@ reduce_outer_joins_pass2(Node *jtnode,
/*
* These could only have been introduced by pull_up_sublinks,
* so there's no way that upper quals could refer to their
- * righthand sides, and no point in checking.
+ * righthand sides, and no point in checking. We don't expect
+ * to see JOIN_RIGHT_ANTI yet.
*/
break;
default: