From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jan Kohnert <nospam001-lists@jan-kohnert.de>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Implementing product-aggregate
Date: Thu, 14 Mar 2024 10:17:58 -0400
Message-ID: <2208194.1710425878@sss.pgh.pa.us> (raw)
In-Reply-To: <9247987.CDJkKcVGEf@kohni-mobil>
References: <2176491.irdbgypaU6@kohni-mobil>
<9247987.CDJkKcVGEf@kohni-mobil>
Jan Kohnert <nospam001-lists@jan-kohnert.de> writes:
> Am Montag, 11. März 2024, 10:16:33 CET schrieb Jan Kohnert:
>> create aggregate prod(numeric) (sfunc = numeric_mul, stype = numeric)
> ...
> Then again, this seems odd, too, since we're only reimplementing basic stuff that's
> already there.
I wouldn't be concerned about relying on numeric_mul (or any of the
other functions underlying standard operators). They're undocumented
only because documenting both the functions and the operators would
bloat the documentation to little purpose. Using one makes your code
not so portable to non-Postgres DBMSes, but you already crossed that
bridge by deciding to use a custom aggregate.
A bigger question is whether this implementation actually has the
properties you want --- notably, maybe you should be using type
float8 not numeric. Numeric would get pretty slow and be carrying
an awful lot of decimal places by the end of the query, I fear.
regards, tom lane
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: tgl@sss.pgh.pa.us, nospam001-lists@jan-kohnert.de
Subject: Re: Implementing product-aggregate
In-Reply-To: <2208194.1710425878@sss.pgh.pa.us>
References: <2176491.irdbgypaU6@kohni-mobil> <9247987.CDJkKcVGEf@kohni-mobil> <2208194.1710425878@sss.pgh.pa.us>
* 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