Re: Allow ILIKE forward matching to use btree index - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Allow ILIKE forward matching to use btree index
Date
Msg-id 1d467b35d09acc2389a3e489ad8519152f4d545b.camel@j-davis.com
Whole thread Raw
In response to Re: Allow ILIKE forward matching to use btree index  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Allow ILIKE forward matching to use btree index
List 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




pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Allow ILIKE forward matching to use btree index
Next
From: Peter Smith
Date:
Subject: Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.