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 1rjbm3-006e4D-JB for pgsql-general@arkaria.postgresql.org; Mon, 11 Mar 2024 09:16:48 +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 1rjbm0-00AzSd-VO for pgsql-general@arkaria.postgresql.org; Mon, 11 Mar 2024 09:16:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rjbm0-00AzSV-JC for pgsql-general@lists.postgresql.org; Mon, 11 Mar 2024 09:16:45 +0000 Received: from jan-kohnert.de ([2001:4ba0:ffa6:da::1]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rjblt-003vSl-19 for pgsql-general@lists.postgresql.org; Mon, 11 Mar 2024 09:16:43 +0000 X-Virus-Scanned: amavisd-new at jan-kohnert.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jan-kohnert.de; s=20191; t=1710148594; bh=0cGgYX3YkmfwEiuwek1lSdcCRdZjfnDfiUlW7ZblD2k=; h=From:To:Subject:Date:From; b=g1RZv5JumNwdNqY7knmzz2KxYJj4MghDqOzHgU5/EsWrZfr1uK8xaOabATktHLmCm 7UtCuEDvc5mPGaEifyJzzC/WG+fz+EIGq/xLchwp+ECxFba0+bKNmSzmLRcPiXpOcL u1dw3v7c47Pc5pP6/dEKjlf+FDNp25pauyZPzqVI1cU6kFmjaSBhmqbbiUw0VrBwL8 krv75xe4x+Ny/ogv4F9/6TtiGgjUXqcMYf0stEv4e+Y7nPY6btpsdVCZ/X7RbQQDnw GkYKWy459C+hEtj1HfGoho5/jUBaPz6DfKNbCTzvPhyyRlmej1bp7BLREXvQGg8kEV LZaoSeYDq6ZwA== Received: from kohni-mobil.localnet (p200300cb872c6191ddd327949971e8e4.dip0.t-ipconnect.de [IPv6:2003:cb:872c:6191:ddd3:2794:9971:e8e4]) by srv21636.dus4.fastwebserver.de (Postfix) with ESMTPSA id 3820B7C0329 for ; Mon, 11 Mar 2024 10:16:34 +0100 (CET) From: Jan Kohnert 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> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="nextPart13469231.uLZWGnKmhe" Content-Transfer-Encoding: 7Bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --nextPart13469231.uLZWGnKmhe Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" 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 --nextPart13469231.uLZWGnKmhe Content-Transfer-Encoding: 7Bit Content-Type: text/html; charset="utf-8"

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

--nextPart13469231.uLZWGnKmhe--