Re: Eager aggregation, take 3

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Tender Wang <tndrwang(at)gmail(dot)com>, Paul George <p(dot)a(dot)george19(at)gmail(dot)com>, Andy Fan <zhihuifan1213(at)163(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Subject: Re: Eager aggregation, take 3
Date: 2026-03-30 03:17:03
Message-ID: CAMbWs48A53PY1Y4zoj7YhxPww9fO1hfnbdntKfA855zpXfVFRA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 9, 2025 at 5:07 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> I noticed an unnecessary header include in initsplan.c. Will fix that
> as well.

I noticed a couple of issues that can lead to unexpected results.
I've attached two patches to fix them.

1. Eager aggregation was incorrectly checking the data type's default
collation rather than the expression's actual collation. This allowed
columns with non-deterministic collations to be pushed down, resulting
in incorrect grouping. Fixed by 0001.

2. Pushing aggregates containing volatile functions below a join
alters their execution count. Fixed by 0002.

(As briefly discussed on Discord, this non-deterministic collation
issue also exists in our long-existing logic for pushing HAVING down
to WHERE. But let's fix it for the eager aggregation first.)

- Richard

Attachment Content-Type Size
v1-0001-Fix-collation-handling-for-grouping-keys-in-eager.patch application/octet-stream 9.3 KB
v1-0002-Fix-volatile-function-evaluation-in-eager-aggrega.patch application/octet-stream 3.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-03-30 03:19:36 Re: Adjust error message for CREATE STATISTICS to account for expressions
Previous Message Ashutosh Bapat 2026-03-30 03:15:36 Re: pg_restore documentation and --create/--single-transaction limitation