Alexander Pyhalov писал(а) 2024-03-25 10:00:
> [email protected] писал(а) 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.
--
Best regards,
Alexander Pyhalov,
Postgres Professional