Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux