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