public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
To: David G. Johnston <[email protected]>
Cc: Zach Aysan <[email protected]>
Cc: Pg Docs <[email protected]>
Subject: Re: Reverse btree indexes
Date: Wed, 23 Jun 2021 12:08:56 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKFQuwYsDe8gVLL66oSDKbDZ6Ln72ygDp=R2CPfd7Ri7acRPkg@mail.gmail.com>
On 2021-Jun-22, David G. Johnston wrote:
> On Tue, Jun 22, 2021 at 2:28 PM Zach Aysan <[email protected]> wrote:
> >> for example, col LIKE 'foo%' or col ~ '^foo', but not col LIKE '%bar',
> >> which would require a reversed index on the field. To use the reversed
> >> index, query with reverse(col) like reverse('%bar').
> >
> This type of commentary isn't usually something we include in the
> documentation...and I'm not too keen on "reversed index" as a phrase
> regardless.
Maybe we can add it as a parenthical comment. Something like
: The optimizer can also use a B-tree index for queries involving the
: pattern matching operators LIKE and ~ if the pattern is a constant and
: is anchored to the beginning of the string — for example, col LIKE
: 'foo%' or col ~ '^foo', but not col LIKE '%bar' (it is possible to
: use an expressional index to support queries such as the latter; see
: Section 11.7). However, [...]
Then add an example in 11.7 Indexes on Expressions below the two
existing examples. I think this is a noteworthy use of expressional
indexes; I've had to explain the reverse() idea a couple of times.
--
Álvaro Herrera 39°49'30"S 73°17'W
"The eagle never lost so much time, as
when he submitted to learn of the crow." (William Blake)
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Reverse btree indexes
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox