Are indexes used with LIKE?

From: Kovács Péter <peter(dot)kovacs(at)chemaxon(dot)hu>
To: pgsql-general(at)postgresql(dot)org
Subject: Are indexes used with LIKE?
Date: 2006-01-23 19:00:01
Message-ID: 43D527B1.1030905@chemaxon.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Are indexes on VARCHAR columns used with the LIKE operator, and if so,
how efficiently are they used?

I can imagine that using indexes can be easy with the starting literal
characters up to the first percent sign such as in:

LIKE 'ZOE%QQWE%'

But, after the first % sign, things can get more difficult.

The reason I am asking is that we are thinking about discriminating
between rows of a table based on a VARCHAR column containing various
one-character "flags". We could then use the LIKE operator for
formulating filter conditions.

Any help is appreciated!

Regards
Peter

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Wilson 2006-01-23 19:06:56 Re: DBMirror.pl performance change
Previous Message Scott Marlowe 2006-01-23 18:50:06 Re: Transact SQL compatibility layer