diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-14 18:48:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-14 18:48:00 +0000 |
commit | e006a24ad152b3faec748afe8c1ff0829699b2e6 (patch) | |
tree | d00e01d25270b4b04aac3c723b9e440a56d8a085 /src/backend/rewrite/rewriteManip.c | |
parent | ef1c807c25b47960aa86cd185fb74371e88d0cbf (diff) | |
download | postgresql-e006a24ad152b3faec748afe8c1ff0829699b2e6.tar.gz postgresql-e006a24ad152b3faec748afe8c1ff0829699b2e6.zip |
Implement SEMI and ANTI joins in the planner and executor. (Semijoins replace
the old JOIN_IN code, but antijoins are new functionality.) Teach the planner
to convert appropriate EXISTS and NOT EXISTS subqueries into semi and anti
joins respectively. Also, LEFT JOINs with suitable upper-level IS NULL
filters are recognized as being anti joins. Unify the InClauseInfo and
OuterJoinInfo infrastructure into "SpecialJoinInfo". With that change,
it becomes possible to associate a SpecialJoinInfo with every join attempt,
which permits some cleanup of join selectivity estimation. That needs to be
taken much further than this patch does, but the next step is to change the
API for oprjoin selectivity functions, which seems like material for a
separate patch. So for the moment the output size estimates for semi and
especially anti joins are quite bogus.
Diffstat (limited to 'src/backend/rewrite/rewriteManip.c')
-rw-r--r-- | src/backend/rewrite/rewriteManip.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 63a8ba2bd05..60492fe3d09 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.107 2008/01/01 19:45:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.108 2008/08/14 18:47:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -176,15 +176,15 @@ OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context) j->rtindex += context->offset; /* fall through to examine children */ } - if (IsA(node, InClauseInfo)) + if (IsA(node, FlattenedSubLink)) { - InClauseInfo *ininfo = (InClauseInfo *) node; + FlattenedSubLink *fslink = (FlattenedSubLink *) node; if (context->sublevels_up == 0) { - ininfo->lefthand = offset_relid_set(ininfo->lefthand, + fslink->lefthand = offset_relid_set(fslink->lefthand, context->offset); - ininfo->righthand = offset_relid_set(ininfo->righthand, + fslink->righthand = offset_relid_set(fslink->righthand, context->offset); } /* fall through to examine children */ @@ -338,16 +338,16 @@ ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context) j->rtindex = context->new_index; /* fall through to examine children */ } - if (IsA(node, InClauseInfo)) + if (IsA(node, FlattenedSubLink)) { - InClauseInfo *ininfo = (InClauseInfo *) node; + FlattenedSubLink *fslink = (FlattenedSubLink *) node; if (context->sublevels_up == 0) { - ininfo->lefthand = adjust_relid_set(ininfo->lefthand, + fslink->lefthand = adjust_relid_set(fslink->lefthand, context->rt_index, context->new_index); - ininfo->righthand = adjust_relid_set(ininfo->righthand, + fslink->righthand = adjust_relid_set(fslink->righthand, context->rt_index, context->new_index); } @@ -589,8 +589,8 @@ rangeTableEntry_used_walker(Node *node, /* fall through to examine children */ } /* Shouldn't need to handle planner auxiliary nodes here */ - Assert(!IsA(node, OuterJoinInfo)); - Assert(!IsA(node, InClauseInfo)); + Assert(!IsA(node, FlattenedSubLink)); + Assert(!IsA(node, SpecialJoinInfo)); Assert(!IsA(node, AppendRelInfo)); if (IsA(node, Query)) |