Re: OLAP CUBE/ROLLUP Operators and GROUP BY grouping sets

From: "Robert Bedell" <robert(at)friendlygenius(dot)com>
To: "'Hannu Krosing'" <hannu(at)tm(dot)ee>
Cc: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: OLAP CUBE/ROLLUP Operators and GROUP BY grouping sets
Date: 2003-12-18 00:15:07
Message-ID: 200312171915885.SM00984@xavier
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> it seems that the longest GROUPING SET and all its left-continuous
> subsets could be collected from the sorted scan and the rest from hash
> aggregates.
>
> GROUPING SET () will always need a "hash" ;)
>
> To optimise any further would require use of statistics data, and is
> probably not a good idea to do before having the simpler one implemented

Absolutely right. That's a good starting point.

> > Any ORDER BY in the query should
> > really be applied after the grouping operation.
> >
> > The CUBE and ROLLUP operators should really be applied by expanding them
> > into the equivalent collections of grouping sets.
>
> For pure ROLLUP one could shortcut the split-into-groups and
> put-together-again process, as ROLLUP is already doable from single
> sorted scan.

Actually as long as the grouping sets are all left-continuous of the longest
grouping set it's doable from a single sorted scan. If done with the right
implementation separating resetable aggregators and out of order aggregators
you could get this optimization for free. This avoids having to look for
ROLLUP specifically.

Cheers,

Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Bedell 2003-12-18 00:26:24 Re: OLAP CUBE/ROLLUP Operators and GROUP BY grouping sets
Previous Message Hannu Krosing 2003-12-18 00:08:34 Re: OLAP CUBE/ROLLUP Operators and GROUP BY grouping sets