Re: JumbleQuery ma treat different GROUP BY expr as the same

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: JumbleQuery ma treat different GROUP BY expr as the same
Date: 2026-01-10 16:46:27
Message-ID: 2546766.1768063587@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

jian he <jian(dot)universality(at)gmail(dot)com> writes:
> explain(costs off, verbose) select count(*) from t group by a;
> explain(costs off, verbose) select count(*) from t group by b;
> explain(costs off, verbose) select count(*) from t group by c;

> JumbleQuery will jumble Query->groupClause, but RangeTblEntry->groupexprs in
> Query->rtable is marked with query_jumble_ignore and therefore excluded from
> jumbling.

> So "group by a" and "group by" merged into the same entry in
> pg_stat_statements,
> Is this what we expected?

It is not what happened before we invented RTE_GROUP. I tried your
experiment in v14 and got:

regression=# SELECT calls, rows, query FROM pg_stat_statements ORDER BY query COLLATE "C";
calls | rows | query
-------+------+---------------------------------------------------------------
1 | 1 | SELECT pg_stat_statements_reset() IS NOT NULL AS t
1 | 0 | explain(costs off, verbose) select count(*) from t group by a
1 | 0 | explain(costs off, verbose) select count(*) from t group by b
1 | 0 | explain(costs off, verbose) select count(*) from t group by c
(4 rows)

So I'm inclined to think this was an unintentional change of behavior.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Vanns 2026-01-10 17:03:24 Re: [PATCH] Add support for SAOP in the optimizer for partial index paths
Previous Message Tom Lane 2026-01-10 16:37:31 Re: Maybe BF "timedout" failures are the client script's fault?