Re: BUG #19517: Eager Aggregation produces wrong count(*) when pushed into RHS of Hash Semi Join

From: "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com>
To: <ihalatci(at)gmail(dot)com>, <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19517: Eager Aggregation produces wrong count(*) when pushed into RHS of Hash Semi Join
Date: 2026-06-10 20:19:09
Message-ID: DJ5NBJ46WCKG.33LJCP1X8ZQH2@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed Jun 10, 2026 at 12:44 PM -03, PG Bug reporting form wrote:
> Likely cause
> ------------
> Eager Aggregation appears to consider the RHS of a SEMI/ANTI join a legal
> site to push a partial aggregate, but for SEMI joins each outer row matches
> at most one inner row by the join's own semantics, so partial counts taken
> on the inner side cannot be combined into a correct outer-side count(*).
> Either eager aggregation must be disabled for the RHS of SEMI/ANTI joins,
> or the partial state must be projected through the semi-join such that
> each surviving outer row contributes exactly one partial.
>
> Two follow-up commits to eager aggregation landed on 2026-04-06
> ("Fix volatile function evaluation in eager aggregation" and
> "Fix collation handling for grouping keys in eager aggregation"), but
> neither addresses semi-join correctness.
>

Wondering if commit ffeda04259b (Fix eager aggregation for semi/antijoin
inner rels) is about fixing this issue. Can you please check it? I think
that 19beta1 was created before the fix was applied on master.

> Search performed before reporting
> ---------------------------------
> - pgsql-bugs archives for 2026-04, 2026-05, and 2026-06: no matching
> report.
> - pgsql-hackers search "eager aggregation semi": 0 hits.
> - pgsql-hackers search "eager aggregation bug": only the original
> development thread by Richard Guo.
> - PostgreSQL 19 Open Items wiki (checked 2026-06-10): not listed under
> Open Issues, Resolved before 19beta1/19beta2, Non-bugs, or Won't Fix.
>

For the reference this previous bug was reported at [1] on eager
aggregation thread.

[1] https://www.postgresql.org/message-id/CAJgoLk+d_P5sKrx-SZt01Acm_j0QnWn6aKJzFJ=waRu_3C8AoQ@mail.gmail.com

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Chernyy 2026-06-11 00:14:36 [PATCH] contrib/xml2: backend crash in xpath_nodeset() on the namespace axis
Previous Message PG Bug reporting form 2026-06-10 15:44:31 BUG #19517: Eager Aggregation produces wrong count(*) when pushed into RHS of Hash Semi Join