Re: Sharing aggregate states between different aggregate functions

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Sharing aggregate states between different aggregate functions
Date: 2015-07-27 06:15:27
Message-ID: CAJrrPGeBgbV5b-Ty_fOGQQjDR5vhE5nLuSfuKdLi2yzMfAP3Ag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 9, 2015 at 7:44 PM, David Rowley
<david(dot)rowley(at)2ndquadrant(dot)com> wrote:
> On 15 June 2015 at 12:05, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> wrote:
>>
>>
>> This basically allows an aggregate's state to be shared between other
>> aggregate functions when both aggregate's transition functions (and a few
>> other things) match
>> There's quite a number of aggregates in our standard set which will
>> benefit from this optimisation.
>>
>
> After compiling the original patch with another compiler, I noticed a couple
> of warnings.
>
> The attached fixes these.

I did some performance tests on the patch. This patch shown good
improvement for same column aggregates. With int or bigint datatype columns,
this patch doesn't show any visible performance difference. But with numeric
datatype it shows good improvement.

select sum(x), avg(y) from test where x < $1;

Different columns:

selectivity Head patch
(millions)
0.1 315 322
0.3 367 376
0.5 419 427
1 551 558
2 824 826

select sum(x), avg(x) from test where x < $1;

Same column:

selectivity Head patch
(millions)
0.1 314 314
0.3 363 343
0.5 412 373
1 536 440
2 795 586

Regards,
Hari Babu
Fujitsu Australia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2015-07-27 06:59:40 Re: MultiXact member wraparound protections are now enabled
Previous Message Andreas Seltenreich 2015-07-27 06:03:29 Re: Failing assertions in indxpath.c, placeholder.c and brin_minmax.c