Re: LIKE, leading percent, bind parameters and indexes

Поиск
Список
Период
Сортировка
От Rodrigo Hjort
Тема Re: LIKE, leading percent, bind parameters and indexes
Дата
Msg-id 731083980605251641q144be605tb9067782c3d8071@mail.gmail.com
обсуждение исходный текст
Ответ на Re: LIKE, leading percent, bind parameters and indexes  (Andrew Sullivan <ajs@crankycanuck.ca>)
Ответы Re: LIKE, leading percent, bind parameters and indexes
Re: LIKE, leading percent, bind parameters and indexes
Список pgsql-hackers
I think more exactly, the planner can't possibly know how to plan an
indexscan with a leading '%', because it has nowhere to start.

The fact is that index scan is performed on LIKE expression on a string not preceded by '%', except when bound parameter is used.

select * from table where field like 'THE NAME%'; -- index scan
select * from table where field like '%THE NAME%'; -- seq scan
select * from table where field like :bind_param; -- seq scan (always)

Regards,

Rodrigo Hjort
http://icewall.org/~hjort

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: XLogArchivingActive
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Gborg and pgfoundry