public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tender Wang <[email protected]>
To: Richard Guo <[email protected]>
Cc: Radim Marek <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: Eager aggregation, take 3
Date: Mon, 1 Jun 2026 15:57:39 +0800
Message-ID: <CAHewXNna2r7cbwuotFJBdsHAedu1hZ1OD1Aj_hoRDOmFw-7z2A@mail.gmail.com> (raw)
In-Reply-To: <CAMbWs49zScoONs0151cmgoo5cttkkK2cGLx228+Wok-h8XoyOg@mail.gmail.com>
References: <CAMbWs48jzLrPt1J_00ZcPZXWUQKawQOFE8ROc-ADiYqsqrpBNw@mail.gmail.com>
<CAJgoLk+d_P5sKrx-SZt01Acm_j0QnWn6aKJzFJ=waRu_3C8AoQ@mail.gmail.com>
<CAHewXNkdhBrQR3mRmLw6FThgXd-tD2LmgfLreb+OeiyXmO2PPQ@mail.gmail.com>
<CAMbWs49zScoONs0151cmgoo5cttkkK2cGLx228+Wok-h8XoyOg@mail.gmail.com>
Richard Guo <[email protected]> 于2026年6月1日周一 15:19写道:
>
> Thanks for the report. This is a bug. We should never push a partial
> aggregation down to a relation on the inner (RHS) side of a semi/anti
> join. A semi/anti join does not preserve its inner rows in the join
> output, so a partial aggregate computed on the inner side would not
> survive the join and could not be combined by the final aggregation.
>
> > I haven't thought about it too deeply yet. Maybe we can do something
> > in the make_grouped_join_rel().
> > ...
> > if (sjinfo->jointype == JOIN_ANTI || sjinfo->jointype == JOIN_SEMI)
> > return;
> > ...
>
> That does fix the reported case, but I think it's too broad: it also
> disables pushing a partial aggregate to the outer side of a semi/anti
> join, which is valid. And by the time we reach make_grouped_join_rel
> the grouped relation for the inner-side relation has already been
> built, so it would just go unused.
Yes, checking only the jointype and concluding that partial agg is not allowed
will cause us to miss some optimization opportunities for the outer
side of the semi or anti-join.
> So I'd rather fix it in eager_aggregation_possible_for_relation, right
> next to the existing outer-join check, by rejecting a relation that
> lies on the inner side of a semijoin/antijoin. See attached.
The attached LGTM.
--
Thanks,
Tender Wang
view thread (55+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Eager aggregation, take 3
In-Reply-To: <CAHewXNna2r7cbwuotFJBdsHAedu1hZ1OD1Aj_hoRDOmFw-7z2A@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox