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 1nk7Sh-00063h-DH for pgsql-general@arkaria.postgresql.org; Thu, 28 Apr 2022 16:57:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nk7Sg-0005VQ-9P for pgsql-general@arkaria.postgresql.org; Thu, 28 Apr 2022 16:57:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk7Sf-0005Un-Uc for pgsql-general@lists.postgresql.org; Thu, 28 Apr 2022 16:57:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk7Sd-0003Mp-Tr for pgsql-general@lists.postgresql.org; Thu, 28 Apr 2022 16:57:49 +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 23SGvdCn023926; Thu, 28 Apr 2022 12:57:39 -0400 From: Tom Lane To: KOPOSOV Sergey cc: "pgsql-general@lists.postgresql.org" Subject: Re: int8range and index usage for <@ operator In-reply-to: <46eb7a6f18a84157e380cd99a47b585ea6413f37.camel@ed.ac.uk> References: <46eb7a6f18a84157e380cd99a47b585ea6413f37.camel@ed.ac.uk> Comments: In-reply-to KOPOSOV Sergey message dated "Thu, 28 Apr 2022 15:38:43 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23924.1651165059.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 28 Apr 2022 12:57:39 -0400 Message-ID: <23925.1651165059@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk KOPOSOV Sergey writes: > I'm trying to understand to is there a possibility to use an index for P= G > when I have a integer column in a table and I want to execute queries wi= th this > integer_column <@ int8range > or > integer_column <@ int8multirange > in a where clause There's no support for that at the moment. In principle the range case could be converted to something like "integer_column >=3D lower_value AND integer_column <=3D upper_value" by attaching a support function to <@ and implementing the SupportRequestIndexCondition API. I think it could only work for a plan-time-constant range though, else you'd not know whether to use equality or inequality bounds. (Hmm ... or maybe, use equality always and treat it as a lossy conversion? But infinite bounds would still be a headache.) regards, tom lane