Re: Inconsistent Behavior of GROUP BY ROLLUP in v17 vs master
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>, 邱宇航 <iamqyh@gmail.com>, Bruce Momjian <bruce@momjian.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-10-17T21:14:02Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix test case from 40c242830
- ee49f2cf447a 18.1 landed
-
Fix pushdown of degenerate HAVING clauses
- 40c2428307b8 18.1 landed
- 18d261409348 19 (unreleased) landed
-
Allow pushdown of HAVING clauses with grouping sets
- 67a54b9e83d3 18.0 cited
-
Mark expressions nullable by grouping sets
- f5050f795aea 18.0 cited
Attachments
- v2-0001-Fix-pushdown-of-degenerate-HAVING-clauses.patch (text/x-diff) patch v2-0001
I wrote: > The proposed patch tries to close the hole by checking whether > the condition is degenerate, but that feels subtly wrong to me: > what we ought to check is whether there is any empty grouping set. > As proposed, I think we miss optimization opportunities for > degenerate HAVING because we will not try the trick of copying > it to WHERE. Concretely, I think we could do the attached. This has the same test query as in v1, but the generated plan is better because it realizes it can copy the constant-false HAVING clause into WHERE, resulting in a dummy scan of the table. I'm not sure if planner.c is the best place to put has_empty_grouping_set(). I couldn't find any existing code doing the same thing, but maybe someday we'd want the functionality elsewhere. regards, tom lane