Re: Partial aggregates pushdown

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: "Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp" <Fujii(dot)Yuki(at)df(dot)mitsubishielectric(dot)co(dot)jp>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Andres Freund <andres(at)anarazel(dot)de>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, vignesh C <vignesh21(at)gmail(dot)com>
Subject: Re: Partial aggregates pushdown
Date: 2024-03-29 14:46:31
Message-ID: f35243f029bf292e297b16774b4d5116@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alexander Pyhalov писал(а) 2024-03-26 14:33:
> Alexander Pyhalov писал(а) 2024-03-25 10:00:
>> Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp писал(а) 2024-03-16 05:28:
>>> Hi. Mr.Pyhalov.
>>>> >>
>>>> >> I don't see it that way. What we would push to the foreign server
>>>> >> would be something like SELECT count(a) FROM t. Then, after we get
>>>> >> the results back and combine the various partial counts locally, we
>>>> >> would locally evaluate the HAVING clause afterward. That is, partial
>>>> >> aggregation is a barrier to pushing down HAVING clause itself, but it
>>>> >> doesn't preclude pushing down the aggregation.
>>>> > I have made modifications in the attached patch to ensure that when
>>>> > the HAVING clause is present, the HAVING clause is executed locally
>>>> > while the partial aggregations are pushed down.
>>>> >
>>>> >
>>>>
>>>> Sorry, I don't see how it works. When we have partial aggregates and
>>>> having clause, foreign_grouping_ok() returns false and
>>>> add_foreign_grouping_paths() adds no paths.
>>>> I'm not saying it's necessary to fix this in the first patch
>>>> version.
>>> Our sincere apologies. I had attached an older version before this
>>> modification.
>>>
>>
>
> Hi.
> Found one more problem. You can fire partial aggregate over partitioned
> table, but convert_combining_aggrefs() will make non-partial copy,
> which leads to
> 'variable not found in subplan target list' error.
>
> Attaching fixed version. Also I've added changes, related to HAVING
> processing.

Hi.

There was an issue in previous patch version - setGroupClausePartial()
looked at root->parse->groupClause, not at root->processed_groupClause.
Fixed and added test to cover this.

Also denied partial agregates pushdown on server version mismatch.
Should check_partial_aggregate_support be 'true' by default?

I'm not sure what to do with current grammar - it precludes partial
distinct aggregates. I understand that it's currently impossible to have
partial aggregation for distinct agregates -but does it worth to have
such restriction at grammar level?

--
Best regards,
Alexander Pyhalov,
Postgres Professional

Attachment Content-Type Size
0001-Partial-aggregates-push-down-SQL-keyword-v4.patch text/x-diff 148.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo NAGATA 2024-03-29 14:47:00 Re: Incremental View Maintenance, take 2
Previous Message Robert Haas 2024-03-29 14:23:16 Re: pg_combinebackup --copy-file-range