Re: Partial aggregates pushdown - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: Partial aggregates pushdown
Date
Msg-id afa9935b-b85f-3e65-7f29-f957da18520b@enterprisedb.com
Whole thread Raw
In response to Re: Partial aggregates pushdown  (Alexander Pyhalov <a.pyhalov@postgrespro.ru>)
List pgsql-hackers
On 10/15/21 17:05, Alexander Pyhalov wrote:
> Tomas Vondra писал 2021-10-15 17:56:
>> Hi Alexander,
>>
> 
> Hi.
> 
>> And then we should extend this for aggregates with more complex
>> internal states (e.g. avg), by supporting a function that "exports"
>> the aggregate state - similar to serial/deserial functions, but needs
>> to be portable.
>>
>> I think the trickiest thing here is rewriting the remote query to call
>> this export function, but maybe we could simply instruct the remote
>> node to use a different final function for the top-level node?
>>
>>
> 
> If we have some special export function, how should we find out that 
> remote server supports this? Should it be server property or should it 
> somehow find out it while connecting to the server?
> 

Good question. I guess there could be some initial negotiation based on 
remote node version etc. And we could also disable this pushdown for 
older server versions, etc.

But after that, I think we can treat this just like other definitions 
between local/remote node - we'd assume they match (i.e. the remote 
server has the export function), and then we'd get an error if it does 
not. If you need to use remote nodes without an export function, you'd 
have to disable the pushdown.

AFAICS this works both for case with explicit query rewrite (i.e. we 
send SQL with calls to the export function) and implicit query rewrite 
(where the remote node uses a different finalize function based on mode, 
specified by GUC).


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Alexander Pyhalov
Date:
Subject: Re: Partial aggregates pushdown
Next
From: Aleksander Alekseev
Date:
Subject: Re: [PATCH] Proposal for HIDDEN/INVISIBLE column