Re: Final Patch for GROUPING SETS

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tomas Vondra <tv(at)fuzzy(dot)cz>, Josh Berkus <josh(at)agliodbs(dot)com>, Atri Sharma <atri(dot)jiit(at)gmail(dot)com>
Subject: Re: Final Patch for GROUPING SETS
Date: 2014-09-19 14:46:36
Message-ID: CABRT9RC=O5qXjD4U0kWtmZRovjK6CJChczk6PmjZJ+S=QYUrgg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 19, 2014 at 4:45 AM, Andrew Gierth
<andrew(at)tao11(dot)riddles(dot)org(dot)uk> wrote:
> GroupAggregate (cost=1122.39..1197.48 rows=9 width=8)
> Group Key: two, four
> Group Key: two
> Group Key: ()

> "Grouping Sets": [
> ["two", "four"],
> ["two"],
> []

+1 looks good to me.

> (yaml format)
> Grouping Sets:
> - - "two"
> - "four"
> - - "two"
> -

Now this is weird. But is anyone actually using YAML output format, or
was it implemented simply "because we can"?

> Marti> Do you think it would be reasonable to normalize single-set
> Marti> grouping sets into a normal GROUP BY?
> It's certainly possible, though it would seem somewhat odd to write
> queries that way.

The reason I bring this up is that queries are frequently dynamically
generated by programs. Coders are unlikely to special-case SQL
generation when there's just a single grouping set. And that's the
power of relational databases: the optimization work is done in the
database pretty much transparently to the coder (when it works, that
is).

> would you want the original syntax preserved in views

Doesn't matter IMO.

> Marti> I'd expect GROUP BY () to be fully equivalent to having no
> Marti> GROUP BY clause, but there's a difference in explain
> Marti> output. The former displays "Grouping Sets: ()" which is odd,
> Marti> since none of the grouping set keywords were used.
> That's an implementation artifact, in the sense that we preserve the
> fact that GROUP BY () was used by using an empty grouping set. Is it
> a problem, really, that it shows up that way in explain?

No, not really a problem. :)

Regards,
Marti

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-09-19 14:54:15 Re: pg_xlogdump --stats
Previous Message Tom Lane 2014-09-19 14:42:21 Re: [REVIEW] Re: Compression of full-page-writes