pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Kohnert <nospam001-lists@jan-kohnert.de>
To: pgsql-general@lists.postgresql.org
Subject: Implementing product-aggregate
Date: Mon, 11 Mar 2024 10:16:33 +0100
Message-ID: <2176491.irdbgypaU6@kohni-mobil> (raw)

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

view thread (4+ messages)  latest in thread

Message-ID: <2176491.irdbgypaU6@kohni-mobil>
Permalink:  ../2176491.irdbgypaU6@kohni-mobil/
Also on:    postgresql.org/message-id/2176491.irdbgypaU6@kohni-mobil

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: nospam001-lists@jan-kohnert.de
  Subject: Re: Implementing product-aggregate
  In-Reply-To: <2176491.irdbgypaU6@kohni-mobil>
  References: <2176491.irdbgypaU6@kohni-mobil>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox