From be3b265c94443b75262e89149f148ace0fdf75da Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 5 Aug 2008 02:43:18 +0000 Subject: 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. --- src/include/nodes/relation.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/include/nodes') 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 */ -- cgit v1.2.3