Re: using for rec inside a function: behavior very slow

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: using for rec inside a function: behavior very slow
Дата
Msg-id 24884.986260616@sss.pgh.pa.us
обсуждение исходный текст
Ответ на using for rec inside a function: behavior very slow  (Jie Liang <jliang@ipinc.com>)
Список pgsql-sql
Jie Liang <jliang@ipinc.com> writes:
>      v_url:= $1||''%'';                
>      for rec in select id,url from urlinfo where url like v_url order by
> url loop

[ is slow ]

LIKE index optimization doesn't happen if the LIKE pattern is a variable
when the plan is created.

In 7.1 you can work around this problem by using plpgsql's FOR ... EXECUTE
notation, but I don't think there's any good answer in 7.0.

for rec in execute ''select id,url from urlinfo where url like ''||quote_literal(v_url)||'' order by url'' loop
        regards, tom lane


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

Предыдущее
От: Jie Liang
Дата:
Сообщение: select statement inside a function: behavior bad
Следующее
От: Tom Lane
Дата:
Сообщение: Re: very very slow .....