Re: Improving avg performance for numeric - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Improving avg performance for numeric
Date
Msg-id CAFj8pRDvpB4NJkUx+iTxVfMcxD3O9KxB6vYTAffh5kdicoDfEw@mail.gmail.com
Whole thread Raw
In response to Re: Improving avg performance for numeric  (Hadi Moshayedi <hadi@moshayedi.net>)
Responses Re: Improving avg performance for numeric
List pgsql-hackers
Hello

I am testing your code, and It increase speed of sum about 24% faster
then original implementation.

But I am surprise of AVG speed - it should have same speed like sum in
new implementation, but it is 2x slower, than sum - what signalize
some strange and there is used wrong transition function

I am sending fixed version

postgres=# create table bubu(a int, b float, c numeric);
CREATE TABLE
postgres=# insert into bubu select i, i+1, i+1.122 from
generate_series(1,1000000) g(i);
INSERT 0 1000000

After fixing a speed of sum and avg for numeric is similar

postgres=# select avg(c) from bubu;
         avg
---------------------
 500001.622000000000
(1 row)

Time: 228.483 ms
postgres=# select sum(c) from bubu;
       sum
------------------
 500001622000.000
(1 row)

Time: 222.791 ms

Regards

Pavel





2013/7/8 Hadi Moshayedi <hadi@moshayedi.net>:
> I am attaching the updated the patch, which also fixes a bug which
> caused one of the regression tests failed.
>
> I'll subscribe this patch to the commitfest in the next hour.
>
> Can you please review the patch?
>
> Thanks,
>    -- Hadi

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Review: Patch to compute Max LSN of Data Pages
Next
From: Kevin Grittner
Date:
Subject: Re: sepgsql and materialized views