From: Tom Lane <tgl@sss.pgh.pa.us>
To: KOPOSOV Sergey <Sergey.Koposov@ed.ac.uk>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: int8range and index usage for <@ operator
Date: Thu, 28 Apr 2022 12:57:39 -0400
Message-ID: <23925.1651165059@sss.pgh.pa.us> (raw)
In-Reply-To: <46eb7a6f18a84157e380cd99a47b585ea6413f37.camel@ed.ac.uk>
References: <46eb7a6f18a84157e380cd99a47b585ea6413f37.camel@ed.ac.uk>
KOPOSOV Sergey <Sergey.Koposov@ed.ac.uk> writes:
> I'm trying to understand to is there a possibility to use an index for PG
> when I have a integer column in a table and I want to execute queries with 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 >= lower_value
AND integer_column <= 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, Sergey.Koposov@ed.ac.uk
Subject: Re: int8range and index usage for <@ operator
In-Reply-To: <23925.1651165059@sss.pgh.pa.us>
References: <46eb7a6f18a84157e380cd99a47b585ea6413f37.camel@ed.ac.uk> <23925.1651165059@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox