Re: Implementing product-aggregate

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Kohnert <nospam001-lists(at)jan-kohnert(dot)de>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Implementing product-aggregate
Date: 2024-03-14 14:17:58
Message-ID: 2208194.1710425878@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jan Kohnert <nospam001-lists(at)jan-kohnert(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thiemo Kellner 2024-03-14 16:41:11 select results on pg_class incomplete
Previous Message Jan Kohnert 2024-03-14 07:36:57 Re: Implementing product-aggregate