On Thu, Mar 31, 2016 at 02:56:48PM -0400, Tom Lane wrote: > Chris Cogdon <chris@xxxxxxxxxx> writes: > > Hi folks! I’ve a query where adding a rollup to the group by switches to > > GroupAggregate unexpectedly, where the standard GROUP BY uses > > HashAggregate. > > The current implementation of rollup doesn't support using hashed > aggregation. I don't know if that's for lack of round tuits or because > it's actually hard, but it's not the planner's fault. > > regards, tom lane > Hi, Cribbed from the mailing list: http://www.postgresql.org/message-id/E1YtRD5-0005Q7-SM@xxxxxxxxxxxxxxxxxxxxxx The current implementation of grouping sets only supports using sorting for input. Individual sets that share a sort order are computed in one pass. If there are sets that don't share a sort order, additional sort & aggregation steps are performed. These additional passes are sourced by the previous sort step; thus avoiding repeated scans of the source data. The code is structured in a way that adding support for purely using hash aggregation or a mix of hashing and sorting is possible. Sorting was chosen to be supported first, as it is the most generic method of implementation. Regards, Ken -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance