Re: is it possible to get the optimizer to use indexes with a like clause - Mailing list pgsql-performance

From Christopher Browne
Subject Re: is it possible to get the optimizer to use indexes with a like clause
Date
Msg-id m34qvxij9d.fsf@wolfe.cbbrowne.com
Whole thread Raw
In response to why do optimizer parameters have to be set manually?  ("Marinos J. Yannikos" <mjy@geizhals.at>)
List pgsql-performance
pg@fastcrypt.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:

pgsql-performance by date:

Previous
From: Dave Cramer
Date:
Subject: Re: is it possible to get the optimizer to use indexes
Next
From: Stephan Szabo
Date:
Subject: Re: is it possible to get the optimizer to use indexes