diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-05 02:43:18 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-05 02:43:18 +0000 |
commit | be3b265c94443b75262e89149f148ace0fdf75da (patch) | |
tree | 198e00992b5716d917d3f900a98f742e1d8228b5 /src/include | |
parent | 4abd7b49f1e9eb1ccc934be5efabb6fd531d0141 (diff) |
Improve SELECT DISTINCT to consider hash aggregation, as well as sort/uniq,
as methods for implementing the DISTINCT step. This eliminates the former
performance gap between DISTINCT and GROUP BY, and also makes it possible
to do SELECT DISTINCT on datatypes that only support hashing not sorting.
SELECT DISTINCT ON is still always implemented by sorting; it would take
executor changes to support hashing that, and it's not clear it's worth
the trouble.
This is a release-note-worthy incompatibility from previous PG versions,
since SELECT DISTINCT can no longer be counted on to deliver sorted output
without explicitly saying ORDER BY. (Anyone who can't cope with that
can consider turning off enable_hashagg.)
Several regression test queries needed to have ORDER BY added to preserve
stable output order. I fixed the ones that manifested here, but there
might be some other cases that show up on other platforms.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/nodes/relation.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 8476d7e85c1..f8c23071661 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.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/relation.h,v 1.156 2008/04/21 20:54:15 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.157 2008/08/05 02:43:17 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -162,8 +162,9 @@ typedef struct PlannerInfo List *query_pathkeys; /* desired pathkeys for query_planner(), and * actual pathkeys afterwards */ - List *group_pathkeys; /* groupClause pathkeys, if any */ - List *sort_pathkeys; /* sortClause pathkeys, if any */ + List *group_pathkeys; /* groupClause pathkeys, if any */ + List *distinct_pathkeys; /* distinctClause pathkeys, if any */ + List *sort_pathkeys; /* sortClause pathkeys, if any */ List *initial_rels; /* RelOptInfos we are now trying to join */ |