From f6dba10e623fa575c8446f854aa63c97d4fedea3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 6 Nov 2002 00:00:45 +0000 Subject: First phase of implementing hash-based grouping/aggregation. An AGG plan node now does its own grouping of the input rows, and has no need for a preceding GROUP node in the plan pipeline. This allows elimination of the misnamed tuplePerGroup option for GROUP, and actually saves more code in nodeGroup.c than it costs in nodeAgg.c, as well as being presumably faster. Restructure the API of query_planner so that we do not commit to using a sorted or unsorted plan in query_planner; instead grouping_planner makes the decision. (Right now it isn't any smarter than query_planner was, but that will change as soon as it has the option to select a hash- based aggregation step.) Despite all the hackery, no initdb needed since only in-memory node types changed. --- src/backend/optimizer/util/pathnode.c | 38 +++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/backend/optimizer/util/pathnode.c') diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 4b3c9809b8b..7dd0dce6891 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.78 2002/06/20 20:29:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.79 2002/11/06 00:00:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -405,7 +405,6 @@ create_tidscan_path(Query *root, RelOptInfo *rel, List *tideval) * create_append_path * Creates a path corresponding to an Append plan, returning the * pathnode. - * */ AppendPath * create_append_path(RelOptInfo *rel, List *subpaths) @@ -433,6 +432,41 @@ create_append_path(RelOptInfo *rel, List *subpaths) return pathnode; } +/* + * create_result_path + * Creates a path corresponding to a Result plan, returning the + * pathnode. + */ +ResultPath * +create_result_path(RelOptInfo *rel, Path *subpath, List *constantqual) +{ + ResultPath *pathnode = makeNode(ResultPath); + + pathnode->path.pathtype = T_Result; + pathnode->path.parent = rel; /* may be NULL */ + + if (subpath) + pathnode->path.pathkeys = subpath->pathkeys; + else + pathnode->path.pathkeys = NIL; + + pathnode->subpath = subpath; + pathnode->constantqual = constantqual; + + if (subpath) + { + pathnode->path.startup_cost = subpath->startup_cost; + pathnode->path.total_cost = subpath->total_cost; + } + else + { + pathnode->path.startup_cost = 0; + pathnode->path.total_cost = cpu_tuple_cost; + } + + return pathnode; +} + /* * create_subqueryscan_path * Creates a path corresponding to a sequential scan of a subquery, -- cgit v1.2.3