Index usage for elem-contained-by-const-range clauses

From: Pritam Baral <pritam(at)pritambaral(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Index usage for elem-contained-by-const-range clauses
Date: 2017-02-22 23:17:02
Message-ID: 1b86eaf1-273f-b8cd-6e9e-5d0bfcb7abb7@pritambaral.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The topic has been previously discussed[0] on the -performance mailing list,
about four years ago.

In that thread, Tom suggested[0] the planner could be made to "expand
"intcol <@
'x,y'::int4range" into "intcol between x and y", using something similar
to the
index LIKE optimization (ie, the "special operator" stuff in indxpath.c)".

This patch tries to do exactly that. It's not tied to any specific datatype,
and has been tested with both builtin types and custom range types. Most
of the
checking for proper datatypes, operators, and btree index happens before
this
code, so I haven't run into any issues yet in my testing. But I'm not
familiar
enough with the internals to be able to confidently say it can handle
all cases
just yet.

[0]:
https://www.postgresql.org/message-id/flat/9860(dot)1364013108%40sss(dot)pgh(dot)pa(dot)us#9860(dot)1364013108(at)sss(dot)pgh(dot)pa(dot)us

--
#!/usr/bin/env regards
Chhatoi Pritam Baral

Attachment Content-Type Size
use-btree-index-in-elem-contained-by-range.patch text/x-patch 6.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2017-02-22 23:24:49 Re: Change in "policy" on dump ordering?
Previous Message Corey Huinker 2017-02-22 23:15:01 Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)