Re: Selecting from a function(x,y) returning a row-type(sum, prod)

Поиск
Список
Период
Сортировка
От Heiko Klein
Тема Re: Selecting from a function(x,y) returning a row-type(sum, prod)
Дата
Msg-id 46383A4C.80409@gmx.net
обсуждение исходный текст
Ответ на Re: Selecting from a function(x,y) returning a row-type(sum, prod)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Thanks,

my real function is quite expensive, so I don't want it to execute
twice. Toms subselect query is therefore exactly what I want, and since
it will be hidden in a view, it doesn't matter that it is a long expression.

Best regards,

Heiko

Tom Lane wrote:

> regression=# select x,y,(f).* from
> regression-#   (select *, sum_n_product(x,y) as f from myvals offset 0) ss;
>  x | y | sum | prod
> ---+---+-----+------
>  1 | 2 |   3 |    2
> (1 row)
>
> The "offset 0" is an optimization fence to keep the planner from
> flattening this form into the form where the function is called twice.
> (As of 8.2, you can dispense with that if the function is marked volatile.)
>

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

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: STDERR vs. SYSLOG logging
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Postgres (selection of thesis topic)