diff options
| author | Tom Lane | 2004-01-05 18:04:39 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-01-05 18:04:39 +0000 |
| commit | 5c74ce23db52ec862b9f35cfa5f6b327820dda47 (patch) | |
| tree | 4fc58b16fa517e704b76c89eed4f451a2de6c2a4 /src/include | |
| parent | cce442da6d6c047b9b86133eb449d3cfbb0fa713 (diff) | |
Improve UniquePath logic to detect the case where the input is already
known unique (eg, it is a SELECT DISTINCT ... subquery), and not do a
redundant unique-ification step.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/relation.h | 21 | ||||
| -rw-r--r-- | src/include/optimizer/clauses.h | 3 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 14486591da9..166f1242b0e 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.91 2004/01/05 05:07:36 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.92 2004/01/05 18:04:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -442,15 +442,26 @@ typedef struct MaterialPath * its subpath. * * This is unlike the other Path nodes in that it can actually generate - * two different plans: either hash-based or sort-based implementation. - * The decision is sufficiently localized that it's not worth having two - * separate Path node types. + * different plans: either hash-based or sort-based implementation, or a + * no-op if the input path can be proven distinct already. The decision + * is sufficiently localized that it's not worth having separate Path node + * types. (Note: in the no-op case, we could eliminate the UniquePath node + * entirely and just return the subpath; but it's convenient to have a + * UniquePath in the path tree to signal upper-level routines that the input + * is known distinct.) */ +typedef enum +{ + UNIQUE_PATH_NOOP, /* input is known unique already */ + UNIQUE_PATH_HASH, /* use hashing */ + UNIQUE_PATH_SORT /* use sorting */ +} UniquePathMethod; + typedef struct UniquePath { Path path; Path *subpath; - bool use_hash; + UniquePathMethod umethod; double rows; /* estimated number of result tuples */ } UniquePath; diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index c948a9039fb..947c4467e7b 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.71 2004/01/04 03:51:52 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.72 2004/01/05 18:04:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -57,6 +57,7 @@ extern bool is_pseudo_constant_clause(Node *clause); extern bool is_pseudo_constant_clause_relids(Node *clause, Relids relids); extern List *pull_constant_clauses(List *quals, List **constantQual); +extern bool has_distinct_clause(Query *query); extern bool has_distinct_on_clause(Query *query); extern int NumRelids(Node *clause); |
