| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | Radim Marek <radim(at)boringsql(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Eager aggregation, take 3 |
| Date: | 2026-06-01 07:57:39 |
| Message-ID: | CAHewXNna2r7cbwuotFJBdsHAedu1hZ1OD1Aj_hoRDOmFw-7z2A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Richard Guo <guofenglinux(at)gmail(dot)com> 于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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ZizhuanLiu X-MAN | 2026-06-01 08:01:58 | Re: [PATCH]Refactor and unify expression construction functions in makefuncs.c |
| Previous Message | Chao Li | 2026-06-01 07:53:11 | Re: pg_stat_statements: Fix normalization of + signs for FETCH and MOVE |