| От | Tom Lane |
|---|---|
| Тема | Re: Query in function not using index... |
| Дата | |
| Msg-id | 6716.1177714602@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Query in function not using index... (Listmail <lists@peufeu.com>) |
| Список | pgsql-general |
Listmail <lists@peufeu.com> writes:
>> Any idea why using a variable v_streetName instead of a string 'wynn%'
>> behaves differently?
> Yeah.
> 'wynn%' doesn't start with % so LIKE uses index.
> But Postgres doesn't know that you know that the contents of this
> variable never starts with '%'...
Even more to the point: the transformation of LIKE 'pattern' into an
index range is a plan-time optimization, so if the planner hasn't got a
constant pattern to work with, it'll never happen. (Yeah, this should
be improved someday.)
If you need to depend on LIKE indexing with non-constant patterns,
you'll have to use EXECUTE to force the query to be replanned each time.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера