Implementing product-aggregate

From: Jan Kohnert <nospam001-lists(at)jan-kohnert(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Implementing product-aggregate
Date: 2024-03-11 09:16:33
Message-ID: 2176491.irdbgypaU6@kohni-mobil
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

we need a product aggregate and used to implement this as

exp(sum(ln([COLUMN])))

While using the sum of logarithms is working RDBMS-independently, we'd like to
switch to a more PostgreSQL native way of doing this and implement an
aggregate to be used. Currently the implementation is

create aggregate prod(numeric) (sfunc = numeric_mul, stype = numeric)

This is simply calling the implementation funtion of the *-Operator for the numeric
datatype. Since I could not find any documentation of this implementation
function, I am wondering, if using a possibly internal function might be a bad idea.

Are there any recommendations on this?

Thanks for any input!

--
MfG Jan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Wiwwo Staff 2024-03-11 10:07:35 Performance (and general) considerations between views and functions
Previous Message Masahiko Sawada 2024-03-11 08:38:17 Re: walsender RAM increases by 500 MB while data is 80 MB