summaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
authorTom Lane2011-03-22 04:34:31 +0000
committerTom Lane2011-03-22 04:34:31 +0000
commit8df08c84894001d3d3f5d10b3290a1063a453316 (patch)
tree138335fc92bf63822f93fd68203b1c97fa4db3c6 /src/backend/nodes
parent6d8096e2f3f2c1296fa880f44f3fa5701b2f40c4 (diff)
Reimplement planner's handling of MIN/MAX aggregate optimization (again).
Instead of playing cute games with pathkeys, just build a direct representation of the intended sub-select, and feed it through query_planner to get a Path for the index access. This is a bit slower than 9.1's previous method, since we'll duplicate most of the overhead of query_planner; but since the whole optimization only applies to rather simple single-table queries, that probably won't be much of a problem in practice. The advantage is that we get to do the right thing when there's a partial index that needs the implicit IS NOT NULL clause to be usable. Also, although this makes planagg.c be a bit more closely tied to the ordering of operations in grouping_planner, we can get rid of some coupling to lower-level parts of the planner. Per complaint from Marti Raudsepp.
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/copyfuncs.c19
-rw-r--r--src/backend/nodes/equalfuncs.c14
-rw-r--r--src/backend/nodes/outfuncs.c5
3 files changed, 4 insertions, 34 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 6e52d36a17e..b903e457a0b 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -1930,22 +1930,6 @@ _copyPlaceHolderInfo(PlaceHolderInfo *from)
return newnode;
}
-/*
- * _copyMinMaxAggInfo
- */
-static MinMaxAggInfo *
-_copyMinMaxAggInfo(MinMaxAggInfo *from)
-{
- MinMaxAggInfo *newnode = makeNode(MinMaxAggInfo);
-
- COPY_SCALAR_FIELD(aggfnoid);
- COPY_SCALAR_FIELD(aggsortop);
- COPY_NODE_FIELD(target);
- COPY_NODE_FIELD(pathkeys);
-
- return newnode;
-}
-
/* ****************************************************************
* parsenodes.h copy functions
* ****************************************************************
@@ -4129,9 +4113,6 @@ copyObject(void *from)
case T_PlaceHolderInfo:
retval = _copyPlaceHolderInfo(from);
break;
- case T_MinMaxAggInfo:
- retval = _copyMinMaxAggInfo(from);
- break;
/*
* VALUE NODES
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 7340aa05251..10b160f537e 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -886,17 +886,6 @@ _equalPlaceHolderInfo(PlaceHolderInfo *a, PlaceHolderInfo *b)
return true;
}
-static bool
-_equalMinMaxAggInfo(MinMaxAggInfo *a, MinMaxAggInfo *b)
-{
- COMPARE_SCALAR_FIELD(aggfnoid);
- COMPARE_SCALAR_FIELD(aggsortop);
- COMPARE_NODE_FIELD(target);
- COMPARE_NODE_FIELD(pathkeys);
-
- return true;
-}
-
/*
* Stuff from parsenodes.h
@@ -2690,9 +2679,6 @@ equal(void *a, void *b)
case T_PlaceHolderInfo:
retval = _equalPlaceHolderInfo(a, b);
break;
- case T_MinMaxAggInfo:
- retval = _equalMinMaxAggInfo(a, b);
- break;
case T_List:
case T_IntList:
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index db4a33c30d1..46435ab21c3 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -1914,7 +1914,10 @@ _outMinMaxAggInfo(StringInfo str, MinMaxAggInfo *node)
WRITE_OID_FIELD(aggfnoid);
WRITE_OID_FIELD(aggsortop);
WRITE_NODE_FIELD(target);
- WRITE_NODE_FIELD(pathkeys);
+ /* We intentionally omit subroot --- too large, not interesting enough */
+ WRITE_NODE_FIELD(path);
+ WRITE_FLOAT_FIELD(pathcost, "%.2f");
+ WRITE_NODE_FIELD(param);
}
static void