On 2021-Jun-22, David G. Johnston wrote:
> On Tue, Jun 22, 2021 at 2:28 PM Zach Aysan <zachaysan@gmail.com> 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)