Re: Combining Aggregates - Mailing list pgsql-hackers

From Kouhei Kaigai
Subject Re: Combining Aggregates
Date
Msg-id 9A28C8860F777E439AA12E8AEA7694F801092F68@BPXM15GP.gisp.nec.co.jp
Whole thread Raw
In response to Re: Combining Aggregates  (Atri Sharma <atri.jiit@gmail.com>)
List pgsql-hackers
Hi Atri,

> So are you proposing not calling transfuncs at all and just use combined
> functions?
> 
No. It is discretion of software component that distribute an aggregate
into multiple partial-aggregates.

> That sounds counterintuitive to me. I am not able to see why you would want
> to avoid transfns totally even for the case of pushing down aggregates that
> you mentioned.
> 
> From Simon's example mentioned upthread:
> 
> PRE-AGGREGATED PLAN
> Aggregate
> -> Join
>      -> PreAggregate (doesn't call finalfn)
>           -> Scan BaseTable1
>      -> Scan BaseTable2
> 
> 
> 
> finalfn wouldnt be called. Instead, combined function would be responsible
> for getting preaggregate results and combining them (unless of course, I
> am missing something).
> 
In this case, aggregate distributor is responsible to mark Aggref correctly.
Aggref in Aggregate-node will call combined-function, then final-function to
generate expected result, but no transition-function shall be called because
we expect state date as its input stream.
On the other hands, Aggref in PreAggregate-node will call transition-function
to accumulate its state-data, but does not call final-function because it is
expected to return state-data as is.

> Special casing transition state updating in Aggref seems like a bad idea
> to me. I would think that it would be better if we made it more explicit
> i.e. add a new node on top that does the combination (it would be primarily
> responsible for calling combined function).
> 
I'm neutral towards above idea. Here is no difference in amount of information,
isn't it?
If we define explicit node types, instead of special flags, it seems to me
the following new nodes are needed.- Aggref that takes individual rows and populate a state data (trans + no-final)-
Aggrefthat takes state data and populate a state data (combined + no-final)- Aggref that takes state data and populate
afinal result (combined + final)
 

Thanks,
--
NEC OSS Promotion Center / PG-Strom Project
KaiGai Kohei <kaigai@ak.jp.nec.com>


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: no test programs in contrib
Next
From: Etsuro Fujita
Date:
Subject: Minor improvement to explain.c