Alexander Pyhalov писал(а) 2024-03-26 14:33:
> 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.
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