On 23 June 2015 at 13:55, Kouhei Kaigai <kai...@ak.jp.nec.com> wrote:
> Once we support to add aggregation path during path consideration, > we need to pay attention morphing of the final target-list according > to the intermediate path combination, tentatively chosen. > For example, if partial-aggregation makes sense from cost perspective; > like SUM(NRows) of partial COUNT(*) AS NRows instead of COUNT(*) on > billion rows, planner also has to adjust the final target-list according > to the interim paths. In this case, final output shall be SUM(), instead > of COUNT(). > > This sounds very much like what's been discussed here: http://www.postgresql.org/message-id/CA+U5nMJ92azm0Yt8TT=hNxFP=vjfhdqfpawfmj+66-4zvcg...@mail.gmail.com The basic concept is that we add another function set to aggregates that allow the combination of 2 states. For the case of MIN() and MAX() this will just be the same as the transfn. SUM() is similar for many types, more complex for others. I've quite likely just borrowed SUM(BIGINT)'s transfer functions to allow COUNT()'s to be combined. More time does need spent inventing the new combining functions that don't currently exist, but that shouldn't matter as it can be done later. Commitfest link to patch here https://commitfest.postgresql.org/5/131/ I see you've signed up to review it! Regards David Rowley -- David Rowley http://www.2ndQuadrant.com/ <http://www.2ndquadrant.com/> PostgreSQL Development, 24x7 Support, Training & Services