Using index for substring search

Started by lecabout 24 years ago2 messagesgeneral
Jump to latest
#1lec
englim@pc.jaring.my

Is it possible for postgreSQL 7.2 to use index search for the following
queries:

select name from item where substring(itemcode,1,3) = '101';
select name from item where itemcode like '101%';

if I have an index on itemcode.

Version 6.5.3 can use index search for the first query.

Thanks,
Thomas.

#2Bruce Momjian
bruce@momjian.us
In reply to: lec (#1)
Re: Using index for substring search

Lec wrote:

Is it possible for postgreSQL 7.2 to use index search for the following
queries:

select name from item where substring(itemcode,1,3) = '101';
select name from item where itemcode like '101%';

if I have an index on itemcode.

Version 6.5.3 can use index search for the first query.

Are you sure? 7.2 and I thought earlier releases could only use an
index on the second query. There is even an FAQ item.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026