Re: Missing Group Key in grouped aggregate

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Erik Nordström <erik(at)timescale(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Missing Group Key in grouped aggregate
Date: 2024-02-20 15:53:58
Message-ID: 185735.1708444438@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?UTF-8?Q?Erik_Nordstr=C3=B6m?= <erik(at)timescale(dot)com> writes:
> I noticed that, beginning with PG16, grouped aggregates are missing the
> "Group Key" in the EXPLAIN output.

> It seems the Agg node has numCols (number of grouping cols) set to zero in
> queries like

> SELECT foo, count(*) FROM bar WHERE foo=1 GROUP BY foo;

> In PG15, the "Group Key" is shown and the Agg node has numCols set as
> expected.

Looks sane to me: the planner now notices that there can only
be one group so it doesn't tell the GroupAgg node to worry about
making groups. If it were missing in a case where there could be
multiple output groups, yes that'd be a bug.

If you want to run it to ground you could bisect to see where the
behavior changed, but you'd probably just find it was intentional.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-02-20 15:55:08 Re: Injection points: some tools to wait and wake
Previous Message Tom Lane 2024-02-20 15:45:51 Re: Change the bool member of the Query structure to bits