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>, "Finnerty, Jim" <jfinnert(at)amazon(dot)com>, 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-26 11:33:21
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.

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

Best regards,
Alexander Pyhalov,
Postgres Professional

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

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2024-03-26 11:51:27 Re: Use streaming read API in ANALYZE
Previous Message shveta malik 2024-03-26 11:19:18 Re: Introduce XID age and inactive timeout based replication slot invalidation