On Thu, Jun 18, 2015 at 9:52 AM, Sven Geggus <li...@fuchsschwanzdomain.de> wrote:
> Raymond O'Donnell <r...@iol.ie> wrote: > > >> mydb=> select myfunc('foo','bar'); > > > > You need to do: > > > > select * from myfunc('foo','bar'); > > This has been a misguided example. Reality should more likely look like > this: > > select myfunc(col1,col2) from mytable; > > And it would of course be undesired if myfunc would be called twice per > row. > So how would this look like to avoid the function beeing called twice? > WITH exec_func AS ( SELECT myfunc(col1,col2) FROM mytable ) SELECT (exec_func.myfunc).* FROM exec_func; This relies on the fact that currently a CTE introduces an optimization barrier. David J.