diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-07 19:35:02 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-07 19:35:02 +0000 |
| commit | af95d7aa63be1d03bad6070d090874d3dfa046e8 (patch) | |
| tree | 8466da3dda219225c516bf87fc521b5ccc86f91c /src/include | |
| parent | 368df3042783778031ece2b8580324516cd42de1 (diff) | |
| download | postgresql-af95d7aa63be1d03bad6070d090874d3dfa046e8.tar.gz | |
Improve INTERSECT/EXCEPT hashing by realizing that we don't need to make any
hashtable entries for tuples that are found only in the second input: they
can never contribute to the output. Furthermore, this implies that the
planner should endeavor to put first the smaller (in number of groups) input
relation for an INTERSECT. Implement that, and upgrade prepunion's estimation
of the number of rows returned by setops so that there's some amount of sanity
in the estimate of which one is smaller.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/plannodes.h | 3 | ||||
| -rw-r--r-- | src/include/optimizer/planmain.h | 6 | ||||
| -rw-r--r-- | src/include/optimizer/tlist.h | 7 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index e2eaadd29f..f0e0d08e03 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.101 2008/08/07 03:04:04 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.102 2008/08/07 19:35:02 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -541,6 +541,7 @@ typedef struct SetOp AttrNumber *dupColIdx; /* their indexes in the target list */ Oid *dupOperators; /* equality operators to compare with */ AttrNumber flagColIdx; /* where is the flag column, if any */ + int firstFlag; /* flag value for first input relation */ long numGroups; /* estimated number of groups in input */ } SetOp; diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 616f0ea2ad..0aa1d32f94 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.109 2008/08/07 03:04:04 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.110 2008/08/07 19:35:02 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -62,8 +62,8 @@ extern Unique *make_unique(Plan *lefttree, List *distinctList); extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, int64 offset_est, int64 count_est); extern SetOp *make_setop(SetOpCmd cmd, SetOpStrategy strategy, Plan *lefttree, - List *distinctList, AttrNumber flagColIdx, long numGroups, - double outputRows); + List *distinctList, AttrNumber flagColIdx, int firstFlag, + long numGroups, double outputRows); extern Result *make_result(PlannerInfo *root, List *tlist, Node *resconstantqual, Plan *subplan); extern bool is_projection_capable_plan(Plan *plan); diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h index 9899b14c82..d2c7f42e05 100644 --- a/src/include/optimizer/tlist.h +++ b/src/include/optimizer/tlist.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/tlist.h,v 1.51 2008/08/07 01:11:52 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/tlist.h,v 1.52 2008/08/07 19:35:02 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,6 +23,9 @@ extern TargetEntry *tlist_member_ignore_relabel(Node *node, List *targetlist); extern List *flatten_tlist(List *tlist); extern List *add_to_flat_tlist(List *tlist, List *vars); +extern List *get_tlist_exprs(List *tlist, bool includeJunk); +extern bool tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK); + extern TargetEntry *get_sortgroupref_tle(Index sortref, List *targetList); extern TargetEntry *get_sortgroupclause_tle(SortGroupClause *sgClause, @@ -37,6 +40,4 @@ extern AttrNumber *extract_grouping_cols(List *groupClause, List *tlist); extern bool grouping_is_sortable(List *groupClause); extern bool grouping_is_hashable(List *groupClause); -extern bool tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK); - #endif /* TLIST_H */ |
