RE: Partial aggregates pushdown - Mailing list pgsql-hackers

From Fujii.Yuki@df.MitsubishiElectric.co.jp"
Subject RE: Partial aggregates pushdown
Date
Msg-id OS3PR01MB66607B671A5C29DED7A41DF39539A@OS3PR01MB6660.jpnprd01.prod.outlook.com
Whole thread Raw
In response to RE: Partial aggregates pushdown  ("Fujii.Yuki@df.MitsubishiElectric.co.jp" <Fujii.Yuki@df.MitsubishiElectric.co.jp>)
Responses Re: Partial aggregates pushdown
List pgsql-hackers
Hi Mr.Pyhalov, hackers.

I have made the following three modifications about this patch.

1)
> <Fujii.Yuki@df.MitsubishiElectric.co.jp>
> Sent: Tuesday, July 18, 2023 10:36 AM
> > From: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
> > Sent: Friday, July 14, 2023 10:40 PM
> > 1) In foreign_join_ok() should we set fpinfo->user if
> > fpinfo->check_partial_aggregate_support is set like it's done for
> > fpinfo->use_remote_estimate? It seems we can end up with fpinfo->user
> > fpinfo->=
> > NULL if use_remote_estimate is not set.
> You are right. I will modify this patch according to your advice.
> Thank you for advice.
Done.

2)
> <Fujii.Yuki@df.MitsubishiElectric.co.jp>
> Sent: Tuesday, July 18, 2023 10:36 AM
> > 2) It seeems we found an additional issue with original patch, which
> > is present in current one. I'm attaching a patch which seems to fix
> > it, but I'm not quite sure in it.
> Thank you for pointing out the issue.
> If a query's group-by clause contains variable based expression(not variable)
> and the query's select clause contains another expression,
> the partial aggregate could be unsafe to push down.
>
> An example of such queries:
> SELECT (b/2)::numeric, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b/2
>
> Your patch disables partial aggregate pushdown for such queries.
> I'll see if we can modify the patch to safely do a partial aggregate pushdown for such queries as well.
> Such a query expects the variable in the select clause expression to be included in the target of the grouped rel
> (let see make_partial_grouping_target),
> but the original groupby clause has no reference to this variable,
> this seems to be the direct cause(let see foreign_grouping_ok).
> I will examine whether a safe pushdown can be achieved by matching the
> groupby clause information referenced by foreign_grouping_ok with the grouped rel target information.
I modified the patch to safely do a partial aggregate pushdown for such queries as well
 by matching the groupby clause information referenced by foreign_grouping_ok with the grouped rel target information.

3)
I modified the patch to safely do a partial aggregate pushdown for queries which contain having clauses.

Sincerely yours,
Yuuki Fujii

--
Yuuki Fujii
Information Technology R&D Center Mitsubishi Electric Corporation

Attachment

pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Use of additional index columns in rows filtering
Next
From: Andres Freund
Date:
Subject: Re: Extension Enhancement: Buffer Invalidation in pg_buffercache