Re: is it possible to get the optimizer to use indexes with a like clause

From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: is it possible to get the optimizer to use indexes with a like clause
Date: 2003-12-19 03:22:38
Message-ID: m34qvxij9d.fsf@wolfe.cbbrowne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

pg(at)fastcrypt(dot)com (Dave Cramer) wrote:
> It appears that the optimizer only uses indexes for = clause?

It can use indices only if there is a given prefix.

Thus:
where text_field like 'A%'

can use the index, essentially transforming this into the clauses

where text_field >= 'A' and
text_field < 'B'.

You can't get much out of an index for
where text_field like '%SOMETHING'
--
(reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc"))
http://www3.sympatico.ca/cbbrowne/wp.html
"When the grammar checker identifies an error, it suggests a
correction and can even makes some changes for you."
-- Microsoft Word for Windows 2.0 User's Guide, p.35:

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Stephan Szabo 2003-12-19 03:36:02 Re: is it possible to get the optimizer to use indexes
Previous Message Dave Cramer 2003-12-19 03:08:37 Re: is it possible to get the optimizer to use indexes