mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
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.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user