Re: dubious optimization of the function in SELECT INTO target list

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: dubious optimization of the function in SELECT INTO target list
Дата
Msg-id 7372.1444167096@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: dubious optimization of the function in SELECT INTO target list  (Oleksii Kliukin <alexk@hintbits.com>)
Ответы Re: dubious optimization of the function in SELECT INTO target list
Список pgsql-general
Oleksii Kliukin <alexk@hintbits.com> writes:
> This should work, but I'm interested in finding out why the original statement behaves the way I�ve described.

plpgsql's SELECT INTO is only capable of storing a single result row,
so it only executes the statement far enough to obtain one row, and
then stops (as though a LIMIT were present).  There is no guarantee
about how much useless computation will get done underneath.

If this is not the behavior you want, you shouldn't be using SELECT INTO
(which, I'll note, is very clearly documented as meant only for single-row
results).  A plausible alternative is a FOR IN SELECT loop, which would
have the benefit that you could actually do something with the row values.

            regards, tom lane


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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: dubious optimization of the function in SELECT INTO target list
Следующее
От: Steve Pribyl
Дата:
Сообщение: backup.old