LIke and Indicies

Поиск
Список
Период
Сортировка
От Dave Smith
Тема LIke and Indicies
Дата
Msg-id 1109349117.14398.50.camel@playpen.candata.com
обсуждение исходный текст
Ответы Re: LIke and Indicies  (Peter Eisentraut <peter_e@gmx.net>)
Re: LIke and Indicies  (Thomas F.O'Connell <tfo@sitening.com>)
Re: LIke and Indicies  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
I am using 7.4.5 and trying to use the like clause (Local C) but
postgres does not seem to want to use the index.

explain
declare t scroll cursor for
select * from product where company_id=1000 and product_desc like 'J%'
 order by company_id,product_desc;

                                   QUERY
PLAN
---------------------------------------------------------------------------------
 Index Scan using product_4 on product  (cost=0.00..12306.67 rows=881
width=181)
   Index Cond: (company_id = 1000)
   Filter: ((product_desc)::text ~~ 'J%'::text)

explain
declare t scroll cursor for
select * from product where company_id=1000 and product_desc >= 'J' and
 product_desc < 'K'
 order by company_id,product_desc;

 QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
 Index Scan using product_4 on product  (cost=0.00..1914.43 rows=881
width=181)
   Index Cond: ((company_id = 1000) AND ((product_desc)::text >=
'J'::text) AND ((product_desc)::text < 'K'::text))


I thought that if you used like and the wildcard was at the end it would
use the index?

--
Dave Smith
CANdata Systems Ltd
416-493-9020


В списке pgsql-general по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Possible to run the server with ANSI/ISO string escapeing
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: LIke and Indicies