From bdfbfde1b168b3332c4cdac34ac86a80aaf4d442 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 20 Jan 2003 18:55:07 +0000 Subject: 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. --- src/backend/utils/adt/selfuncs.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/backend/utils/adt/selfuncs.c') 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); -- cgit v1.2.3