Re: GROUP BY ALL

2023-01-06 Thread Andrey Borodin
On Fri, Jan 6, 2023 at 1:56 PM Bruce Momjian wrote: > Because Postgres requires GROUP BY > of all non-aggregate columns of a target list, Postgres could certainly > automatically generate the GROUP BY. However, readers of the query > might not easily distinguish function calls fro

Re: GROUP BY ALL

2023-01-06 Thread Bruce Momjian
what my opinion is on that. This is a very interesting concept. Because Postgres requires GROUP BY of all non-aggregate columns of a target list, Postgres could certainly automatically generate the GROUP BY. However, readers of the query might not easily distinguish function calls from aggregates, so in

Re: GROUP BY ALL

2022-12-19 Thread Vik Fearing
On 12/19/22 05:19, Andrey Borodin wrote: Hi hackers! I saw a thread in a social network[0] about GROUP BY ALL. The idea seems useful. I always was writing something like select datname, usename, count(*) from pg_stat_activity group by 1,2; and then rewriting to select datname, usename

Re: GROUP BY ALL

2022-12-19 Thread Isaac Morland
On Sun, 18 Dec 2022 at 23:30, Tom Lane wrote: > Andrey Borodin writes: > > I saw a thread in a social network[0] about GROUP BY ALL. The idea seems > useful. > > Isn't that just a nonstandard spelling of SELECT DISTINCT? > In a pure relational system, yes; but since Post

Re: GROUP BY ALL

2022-12-18 Thread David G. Johnston
On Sunday, December 18, 2022, Tom Lane wrote: > Andrey Borodin writes: > > I saw a thread in a social network[0] about GROUP BY ALL. The idea seems > useful. > > Isn't that just a nonstandard spelling of SELECT DISTINCT? > > What would happen if there are aggregate funct

Re: GROUP BY ALL

2022-12-18 Thread Andrey Borodin
On Sun, Dec 18, 2022 at 8:30 PM Tom Lane wrote: > > I'm not especially on board with "ALL" meaning "ALL (oh, but not > aggregates)". Yes, that's the weak part of the proposal. I even thought about renaming it to "GROUP BY SOMEHOW" or even "GROUP BY SURPRISE ME". I mean I see some cases when it's

Re: GROUP BY ALL

2022-12-18 Thread Tom Lane
Andrey Borodin writes: > I saw a thread in a social network[0] about GROUP BY ALL. The idea seems > useful. Isn't that just a nonstandard spelling of SELECT DISTINCT? What would happen if there are aggregate functions in the tlist? I'm not especially on board with "ALL"

GROUP BY ALL

2022-12-18 Thread Andrey Borodin
Hi hackers! I saw a thread in a social network[0] about GROUP BY ALL. The idea seems useful. I always was writing something like select datname, usename, count(*) from pg_stat_activity group by 1,2; and then rewriting to select datname, usename, query, count(*) from pg_stat_activity group