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 1rkpnJ-00FmMn-Rc for pgsql-general@arkaria.postgresql.org; Thu, 14 Mar 2024 18:27:10 +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 1rkpnH-0028RK-SG for pgsql-general@arkaria.postgresql.org; Thu, 14 Mar 2024 18:27:08 +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 1rkpnH-0028R9-Fb for pgsql-general@lists.postgresql.org; Thu, 14 Mar 2024 18:27:08 +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 1rkpnA-004VYU-1j for pgsql-general@lists.postgresql.org; Thu, 14 Mar 2024 18:27:06 +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=1710440818; bh=b6Uton812xPlbnGz28ouacOdkpT8ZP+hLQgMImAjRqA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=miZNgfkYmLqm6C/mkkBVPB3QEevC+myq1KkMcxw6FbE3VKVSZsJmq1lWJhnd93DOR zsg0M4lFh9NbPm8SwLtqhQLAjB55mhbzetYOp/ygBI8NSlNZ95RuBRF1ktEc3NgGvD FMQvqeAvmnKenavFeFwflFQOAGqPMP5Eb5qHDyScJAYV2Qoqnt4RlgA1d2bxlzkXZk Gz1TX50anLqOxlz+B3NvIW+3SucTDeGinAQh5YGW5Ws00dJeXRfqfVnwER3HOV6u0t wlpZCcqJj84h85BEYGVE5MmlbWbl23nRbhNq7C3ZT09HyowQw9xmBwmcCFbsPSww+O JhJp8CtJdAhxw== Received: from kohni-mobil.localnet (p200300cb872c61e532a8349bcc55b9ba.dip0.t-ipconnect.de [IPv6:2003:cb:872c:61e5:32a8:349b:cc55:b9ba]) by srv21636.dus4.fastwebserver.de (Postfix) with ESMTPSA id 4D9E77C0149 for ; Thu, 14 Mar 2024 19:26:58 +0100 (CET) From: Jan Kohnert To: pgsql-general@lists.postgresql.org Subject: Re: Implementing product-aggregate Date: Thu, 14 Mar 2024 19:26:57 +0100 Message-ID: <2646220.k3LOHGUjKi@kohni-mobil> In-Reply-To: <2208194.1710425878@sss.pgh.pa.us> References: <2176491.irdbgypaU6@kohni-mobil> <9247987.CDJkKcVGEf@kohni-mobil> <2208194.1710425878@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="nextPart2114227.bB369e8A3T" 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. --nextPart2114227.bB369e8A3T Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hello, Am Donnerstag, 14. M=C3=A4rz 2024, 15:17:58 CET schrieb Tom Lane: > 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. thank you for clearifying this. We're not too concerned about portability. = Let's face=20 the facts: Porting a reasonably complex database and the application using = it=20 from one DBMS to another will almost certainly introduce an awful lot of=20 portability issues (f.e. the pseudo-types (big)serial, upserts, differences= in merge=20 implementations, progammability, and so on). My main concern was, that=20 undocumented features sometimes tend to change without notice, since users= =20 are not expected to use them.. =20 > 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. This needs to be checked on our side. I was expecting, that using an aggreg= ate=20 this way would be significantly faster than using exp(sum(log())). Though w= e're=20 not multiplying too many lines in a statement, if using the aggregate slows= down=20 performance, we should propably stick the old way doing it. Best regards! =2D-=20 MfG Jan --nextPart2114227.bB369e8A3T Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

Hello,


Am Donnerstag, 14. M=C3=A4rz 2024, 15:17:58 CET schrieb Tom Lane:

>= ; I wouldn't be concerned about relying on numeric_mul (or any of the

>= ; other functions underlying standard operators).  They're undocumente= d

>= ; only because documenting both the functions and the operators would

>= ; bloat the documentation to little purpose.  Using one makes your cod= e

>= ; not so portable to non-Postgres DBMSes, but you already crossed that

>= ; bridge by deciding to use a custom aggregate.


thank you for clearifying this. We're not too concerned about portabilit= y. Let's face the facts: Porting a reasonably complex database and the appl= ication using it from one DBMS to another will almost certainly introduce a= n awful lot of portability issues (f.e. the pseudo-types (big)serial, upser= ts, differences in merge implementations, progammability, and so on). My ma= in concern was, that undocumented features sometimes tend to change without= notice, since users are not expected to use them..

&nb= sp;

>= ; 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.


This needs to be checked on our side. I was expecting, that using an agg= regate this way would be significantly faster than using exp(sum(log())). T= hough we're not multiplying too many lines in a statement, if using the agg= regate slows down performance, we should propably stick the old way doing i= t.


Best regards!


--

MfG= Jan

--nextPart2114227.bB369e8A3T--