aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/outfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-08-21 03:49:17 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-08-21 03:49:17 +0000
commitdb436adf761bd5cb7990745ceba2959ac4bfca7c (patch)
tree8878ce970fd9b3ac480f3c5ef953fbc85827e685 /src/backend/nodes/outfuncs.c
parent5588c559e6e21fae6ba1f162616f4fb4f680fb31 (diff)
downloadpostgresql-db436adf761bd5cb7990745ceba2959ac4bfca7c.tar.gz
postgresql-db436adf761bd5cb7990745ceba2959ac4bfca7c.zip
Major revision of sort-node handling: push knowledge of query
sort order down into planner, instead of handling it only at the very top level of the planner. This fixes many things. An explicit sort is now avoided if there is a cheaper alternative (typically an indexscan) not only for ORDER BY, but also for the internal sort of GROUP BY. It works even when there is no other reason (such as a WHERE condition) to consider the indexscan. It works for indexes on functions. It works for indexes on functions, backwards. It's just so cool... CAUTION: I have changed the representation of SortClause nodes, therefore THIS UPDATE BREAKS STORED RULES. You will need to initdb.
Diffstat (limited to 'src/backend/nodes/outfuncs.c')
-rw-r--r--src/backend/nodes/outfuncs.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 39b0625d933..226dbb1cef0 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: outfuncs.c,v 1.93 1999/08/16 02:17:42 tgl Exp $
+ * $Id: outfuncs.c,v 1.94 1999/08/21 03:48:58 tgl Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -237,18 +237,15 @@ _outQuery(StringInfo str, Query *node)
static void
_outSortClause(StringInfo str, SortClause *node)
{
- appendStringInfo(str, " SORTCLAUSE :resdom ");
- _outNode(str, node->resdom);
-
- appendStringInfo(str, " :opoid %u ", node->opoid);
+ appendStringInfo(str, " SORTCLAUSE :tleSortGroupRef %d :sortop %u ",
+ node->tleSortGroupRef, node->sortop);
}
static void
_outGroupClause(StringInfo str, GroupClause *node)
{
- appendStringInfo(str, " GROUPCLAUSE :grpOpoid %u :tleGroupref %d",
- node->grpOpoid,
- node->tleGroupref);
+ appendStringInfo(str, " GROUPCLAUSE :tleSortGroupRef %d :sortop %u ",
+ node->tleSortGroupRef, node->sortop);
}
/*
@@ -482,9 +479,6 @@ _outAgg(StringInfo str, Agg *node)
appendStringInfo(str, " AGG ");
_outPlanInfo(str, (Plan *) node);
-
- appendStringInfo(str, " :aggs ");
- _outNode(str, node->aggs);
}
static void
@@ -549,8 +543,8 @@ _outResdom(StringInfo str, Resdom *node)
node->reskey,
node->reskeyop);
- appendStringInfo(str, " :resgroupref %d :resjunk %s ",
- node->resgroupref,
+ appendStringInfo(str, " :ressortgroupref %d :resjunk %s ",
+ node->ressortgroupref,
node->resjunk ? "true" : "false");
}
@@ -665,8 +659,7 @@ _outAggref(StringInfo str, Aggref *node)
node->aggtype);
_outNode(str, node->target);
- appendStringInfo(str, ":aggno %d :usenulls %s",
- node->aggno,
+ appendStringInfo(str, " :usenulls %s ",
node->usenulls ? "true" : "false");
}