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

Re: creating new aggregate function

From: "Webb Sprague" <webb(dot)sprague(at)gmail(dot)com>
To: Justin <justin(at)emproshunts(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: creating new aggregate function
Date: 2008-02-29 19:32:43
Message-ID: b11ea23c0802291132s272e0680s8e768645f32e4f77@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
This probably belongs on General, but

On Fri, Feb 29, 2008 at 9:11 AM, Justin <justin(at)emproshunts(dot)com> wrote:
> Need help and direction  creating new aggregate functions.
>
>  We need to add more average functions for both scientific and finical
>  purposes
>
>  RMS for electrical measurement purposes
>  Mode for both electrical and finical
>  Weighted Average  finical  purposes
>  Generalized mean for electrical measurement purposes
>  Geometric mean for electrical measurement purposes
>  Harmonic mean for electrical measurement purposes
>
>  what would be the best way to create these new functions??

Have you already read the documentation  on creating aggregates?  Have
you tried something and it didn't work, or are you interested in
design ideas?  I would just knock together something in plpgsql.  If
you have trouble, send the specific questions to the list.

"best"  ?  C is fastest, etc -- what kind of tradeoffs do you need to satisfy?

One thing worth thinking about is using arrays to carry state from one
function call to the next in an aggregate; this is how the function
used in the average aggregate keeps track of both the running total
and the number of rows.  The Stdev uses a three item array similarly.

>
>
>  ---------------------------(end of broadcast)---------------------------
>  TIP 6: explain analyze is your friend
>

In response to

pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2008-02-29 19:42:27
Subject: Re: bug or not bug, xmlvalidate(xml, text) can read andshow one line from file
Previous:From: Peter EisentrautDate: 2008-02-29 19:30:10
Subject: Re: bug or not bug, xmlvalidate(xml, text) can read and show one line from file

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