diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-20 18:55:07 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-20 18:55:07 +0000 |
commit | bdfbfde1b168b3332c4cdac34ac86a80aaf4d442 (patch) | |
tree | f35bf1af04733069f3a6b0a2698ac10dbd6544ed /src/backend/utils/adt/selfuncs.c | |
parent | be2b660ecd5ca205570825633e7b8479379ddc64 (diff) | |
download | postgresql-bdfbfde1b168b3332c4cdac34ac86a80aaf4d442.tar.gz postgresql-bdfbfde1b168b3332c4cdac34ac86a80aaf4d442.zip |
IN clauses appearing at top level of WHERE can now be handled as joins.
There are two implementation techniques: the executor understands a new
JOIN_IN jointype, which emits at most one matching row per left-hand row,
or the result of the IN's sub-select can be fed through a DISTINCT filter
and then joined as an ordinary relation.
Along the way, some minor code cleanup in the optimizer; notably, break
out most of the jointree-rearrangement preprocessing in planner.c and
put it in a new file prep/prepjointree.c.
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index fe6f38eee85..42ad9f5f94b 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.126 2003/01/15 19:35:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.127 2003/01/20 18:54:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1825,8 +1825,7 @@ mergejoinscansel(Query *root, Node *clause, * * Inputs: * root - the query - * groupClauses - list of GroupClauses (or SortClauses for the DISTINCT - * case, but those are equivalent structs) + * groupExprs - list of expressions being grouped by * input_rows - number of rows estimated to arrive at the group/unique * filter step * @@ -1867,7 +1866,7 @@ mergejoinscansel(Query *root, Node *clause, * do better). */ double -estimate_num_groups(Query *root, List *groupClauses, double input_rows) +estimate_num_groups(Query *root, List *groupExprs, double input_rows) { List *allvars = NIL; List *varinfos = NIL; @@ -1879,14 +1878,12 @@ estimate_num_groups(Query *root, List *groupClauses, double input_rows) } MyVarInfo; /* We should not be called unless query has GROUP BY (or DISTINCT) */ - Assert(groupClauses != NIL); + Assert(groupExprs != NIL); /* Step 1: get the unique Vars used */ - foreach(l, groupClauses) + foreach(l, groupExprs) { - GroupClause *grpcl = (GroupClause *) lfirst(l); - Node *groupexpr = get_sortgroupclause_expr(grpcl, - root->targetList); + Node *groupexpr = (Node *) lfirst(l); List *varshere; varshere = pull_var_clause(groupexpr, false); |