Re: Partial Aggregation / GROUP BY before JOIN

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Partial Aggregation / GROUP BY before JOIN
Date: 2015-09-29 00:24:20
Message-ID: 5609DA34.7000306@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015/09/28 20:58, David Rowley wrote:
> On 28 September 2015 at 23:17, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kouhei Kaigai 2015-09-29 00:31:11 Re: CustomScan support on readfuncs.c
Previous Message Kouhei Kaigai 2015-09-29 00:13:36 Re: Foreign join pushdown vs EvalPlanQual