Re: Function use in query

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Function use in query
Date: 2013-06-06 20:17:58
Message-ID: 1370549878872-5758201.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ioana Danes wrote
> create view tmp_view as
> with func as (
>     select tmp_Cashdrawer.CashdrawerID, test1(tmp_Cashdrawer.CashdrawerID)
> as call
>     from tmp_Cashdrawer
> )
> select func.CashdrawerID, (func.call).*
> from func;

So yeah, putting this into a view will not work. The WITH/CTE construct is
an optimization barrier so the WHERE clause that is going to be used cannot
be applied before the function call is performed - only afterwards.

As I said before LATERAL in 9.3 may help - though others will have to
comment - in cleaning up the syntax and multiple-calls.

For <= 9.2 you will have to either live with the slightly verbose syntax or
wrap what you need into user-defined functions.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Function-use-in-query-tp5758051p5758201.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ray Cote 2013-06-06 21:12:51 Re: Database performs massive reads when I'm doing writes.
Previous Message Jeff Janes 2013-06-06 20:05:28 Re: Database performs massive reads when I'm doing writes.