Re: Why indexes are not used when scanning from functions?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Why indexes are not used when scanning from functions?
Дата
Msg-id 16262.990642498@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Why indexes are not used when scanning from functions?  ("Ловпаче Айдамир" <aidanet@yandex.ru>)
Список pgsql-sql
"Ловпаче Айдамир" <aidanet@yandex.ru> writes:
> create function get_fio1(text) returns varchar
> as 'select fio from patient_temp where fio like $1::text || \'%\';'  
> language 'sql';

You won't get an indexscan for this because the LIKE pattern is not
a constant at planning time, and so the planner cannot extract indexscan
bounds from it.

In 7.1 it's possible to obtain the desired result in plpgsql, by using
EXECUTE.  You'd need to substitute the pattern into the query string
as a literal constant, not as a plpgsql variable.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: index/join madness
Следующее
От: "Diehl, Jeffrey"
Дата:
Сообщение: Error msg.