On Fri, Sep 19, 2014 at 4:45 AM, Andrew Gierth
<and...@tao11.riddles.org.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

> 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. :)


Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to