Re: Allow ILIKE forward matching to use btree index

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Allow ILIKE forward matching to use btree index
Date: 2025-01-15 22:40:19
Message-ID: 1d467b35d09acc2389a3e489ad8519152f4d545b.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

My apologies, I sent the previous email prematurely. Let me try again:

On Wed, 2025-01-15 at 14:34 -0800, Jeff Davis wrote:
> On Wed, 2025-01-15 at 01:40 +0900, Yugo NAGATA wrote:
> > > > For example, "t ~~ '123foo%'" is converted to "(t >= '123foo'
> > > > AND
> > > > t < '123fop')"
> > > > and index scan can be used for this condition. On the other
> > > > hand,
> > > > "t ~~* '123foo'"
> > > > cannot be converted and sequential scan is used.
> > > >
> > > > Even in this case, we can use a bitmap index scan for the
> > > > condition
> > > > "(t >= '123f' AND t < '123g') OR "(t >= '123F' AND t < '123G')"
> > > > followed by
> > > > recheck by the original condition "t ~~* '123foo'", and this
> > > > could be faster
> > > > than seqscan.

In theory, there could be many OR clauses:

(t >= '123foo' AND t < '123fop') OR
(t >= '123Foo' AND t < '123Fop') OR
(t >= '123fOo' AND t < '123fOp') OR
(t >= '123FOo' AND t < '123FOp') OR
...

How should that be limited?

> > >
Regards,
Jeff Davis

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-01-15 23:22:39 Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.
Previous Message Jeff Davis 2025-01-15 22:34:52 Re: Allow ILIKE forward matching to use btree index