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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-hackers by date

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