Thread: Using index for substring search

Using index for substring search

From
Lec
Date:
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.


Re: Using index for substring search

From
Bruce Momjian
Date:
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