Re: Adding a ROLLUP switches to GroupAggregate unexpectedly - Mailing list pgsql-performance

From ktm@rice.edu
Subject Re: Adding a ROLLUP switches to GroupAggregate unexpectedly
Date
Msg-id 20160331190803.GH29284@aart.rice.edu
Whole thread Raw
In response to Re: Adding a ROLLUP switches to GroupAggregate unexpectedly  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
On Thu, Mar 31, 2016 at 02:56:48PM -0400, Tom Lane wrote:
> Chris Cogdon <chris@cogdon.org> 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@gemulon.postgresql.org

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


pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Adding a ROLLUP switches to GroupAggregate unexpectedly
Next
From: Jarek
Date:
Subject: Big number of connections