Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rkluV-00FDaO-Gc for pgsql-general@arkaria.postgresql.org; Thu, 14 Mar 2024 14:18:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rkluU-000Qjr-18 for pgsql-general@arkaria.postgresql.org; Thu, 14 Mar 2024 14:18:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rkluT-000QjZ-Mh for pgsql-general@lists.postgresql.org; Thu, 14 Mar 2024 14:18:18 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rkluN-004UkE-1L for pgsql-general@lists.postgresql.org; Thu, 14 Mar 2024 14:18:17 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 42EEHwSm2208195; Thu, 14 Mar 2024 10:17:59 -0400 From: Tom Lane To: Jan Kohnert cc: pgsql-general@lists.postgresql.org Subject: Re: Implementing product-aggregate In-reply-to: <9247987.CDJkKcVGEf@kohni-mobil> References: <2176491.irdbgypaU6@kohni-mobil> <9247987.CDJkKcVGEf@kohni-mobil> Comments: In-reply-to Jan Kohnert message dated "Thu, 14 Mar 2024 08:36:57 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2208193.1710425878.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 14 Mar 2024 10:17:58 -0400 Message-ID: <2208194.1710425878@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jan Kohnert writes: > Am Montag, 11. M=C3=A4rz 2024, 10:16:33 CET schrieb Jan Kohnert: >> create aggregate prod(numeric) (sfunc =3D numeric_mul, stype =3D numeri= c) > ... > Then again, this seems odd, too, since we're only reimplementing basic s= tuff 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