Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNESG-0006El-JH for pgsql-bugs@arkaria.postgresql.org; Wed, 01 Feb 2023 14:51:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pNESF-00085F-60 for pgsql-bugs@arkaria.postgresql.org; Wed, 01 Feb 2023 14:51:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNESE-000856-Td for pgsql-bugs@lists.postgresql.org; Wed, 01 Feb 2023 14:51:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNESC-0003kj-QY for pgsql-bugs@lists.postgresql.org; Wed, 01 Feb 2023 14:51: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 311EpBL91367183; Wed, 1 Feb 2023 09:51:11 -0500 From: Tom Lane To: Alvaro Herrera cc: David Rowley , Pavel Stehule , Duncan Sands , pgsql-bugs@lists.postgresql.org Subject: Re: range_agg extremely slow compared to naive implementation in obscure circumstances In-reply-to: <20230201115741.qfcjbm4jyji4etvn@alvherre.pgsql> References: <20230201115741.qfcjbm4jyji4etvn@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 01 Feb 2023 12:57:41 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1367181.1675263071.1@sss.pgh.pa.us> Date: Wed, 01 Feb 2023 09:51:11 -0500 Message-ID: <1367182.1675263071@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > On 2023-Jan-31, David Rowley wrote: >> It might be better if we had multirange_canonicalize() deserialize >> these once and used some representation that could more easily be >> qsorted. I'm not planning on doing any work on it though. > Yeah, maybe it would be possible to have an in-memory representation > that doesn't require any deparsing, and keep the compact representation > to be used only for in-data-page storage. How to do this within the > constraints of the Datum abstraction is not clear to me. Perhaps the "expanded datum" mechanism would serve? src/include/utils/expandeddatum.h It might be too heavyweight for this application, but I'm not sure. regards, tom lane