Skip site navigation (1) Skip section navigation (2)

Re: Avg performance for int8/numeric

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, "eng(at)intranet(dot)greenplum(dot)com" <eng(at)intranet(dot)greenplum(dot)com>
Subject: Re: Avg performance for int8/numeric
Date: 2006-11-24 15:27:10
Message-ID: 200611241527.kAOFRAS11857@momjian.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
This has been saved for the 8.3 release:

	http://momjian.postgresql.org/cgi-bin/pgpatches_hold

---------------------------------------------------------------------------

Mark Kirkwood wrote:
> Avg performance for these two datatypes can be improved by *not* 
> calculating the sum of squares in the shared accumulator 
> (do_numeric_accum). However there is a little subtlety as this function 
> is also the shared by variance and stddev!
> 
> This patch:
> 
> - Modifies do_numeric_accum to have an extra bool parameter and does not 
> calc sumX2 when it is false.
> - Amends all the accumulators that call it to include the bool (set to 
> true).
> - Adds new functions [int8|numeric]_avg_accum that call do_numeric_accum 
> with the bool set to false.
> - Amends the the bootstrap entries for pg_aggregate to use the new 
> accumulators for avg(int8|numeric).
> - Adds the new accumulators into the bootstrap entries for pg_proc.
> 
> Performance gain is approx 33% (it is still slower than doing sum/count 
> - possibly due to the construct/deconstruct overhead of the numeric 
> transition array).
> 
> Cheers
> 
> Mark


> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>        message can get through to the mailing list cleanly

-- 
  Bruce Momjian   bruce(at)momjian(dot)us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2006-11-24 16:26:46
Subject: Re: Day and month name localization uses wrong locale category
Previous:From: Bruce MomjianDate: 2006-11-24 15:26:33
Subject: Re: Day and month name localization uses wrong

pgsql-patches by date

Next:From: Bruce MomjianDate: 2006-11-24 18:58:45
Subject: Re: [PERFORM] Direct I/O issues
Previous:From: Tom LaneDate: 2006-11-24 04:18:12
Subject: Re: Avg performance for int8/numeric

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group