Re: Partial Aggregation / GROUP BY before JOIN - Mailing list pgsql-hackers

From Amit Langote
Subject Re: Partial Aggregation / GROUP BY before JOIN
Date
Msg-id 5609DA34.7000306@lab.ntt.co.jp
Whole thread Raw
In response to Re: Partial Aggregation / GROUP BY before JOIN  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-hackers
On 2015/09/28 20:58, David Rowley wrote:
> On 28 September 2015 at 23:17, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
> wrote:
>> Moreover, would partial aggregation work below Append?
>>
> 
> Do you mean for cases like:
> 
> create table a as select x.x a from generate_series(1,1000000) x(x);
> select sum(a) from (select a from a union all select a from a) a;
> 
> to allow the aggregation to happen before the append?
> 

Yes.

> On testing this I do see that writing the query as:
> 
> select sum(a) from (select sum(a) a from a union all select sum(a) from a)
> a;
> 
> causes it to execute marginally faster. 174.280 ms vs 153.498 ms on my
> laptop.
> However pushing aggregation below Append nodes is not something I'm aiming
> to do for this patch.

I see. I recall reading in archives that pushing aggregates below append
was not found to make much difference as your little test suggests, too.

Thanks,
Amit





pgsql-hackers by date:

Previous
From: Kouhei Kaigai
Date:
Subject: Re: Foreign join pushdown vs EvalPlanQual
Next
From: Kouhei Kaigai
Date:
Subject: Re: CustomScan support on readfuncs.c