Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2AF709FA4AB for ; Mon, 15 Oct 2007 13:09:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 19177-04 for ; Mon, 15 Oct 2007 13:09:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158]) by postgresql.org (Postfix) with ESMTP id 39D9E9F9A68 for ; Mon, 15 Oct 2007 13:09:27 -0300 (ADT) Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1IhSVS-0003TT-DE for pgsql-performance@postgresql.org; Mon, 15 Oct 2007 09:09:26 -0700 Message-ID: <13216092.post@talk.nabble.com> Date: Mon, 15 Oct 2007 09:09:25 -0700 (PDT) From: chrisj To: pgsql-performance@postgresql.org Subject: using a stored proc that returns a result set in a complex SQL stmt MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: chrisj.wood@sympatico.ca X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.03 tagged_above=0 required=5 tests=BAYES_00=-2.599, DNS_FROM_OPENWHOIS=1.13, WHOIS_MYPRIVREG=1.499 X-Spam-Level: X-Archive-Number: 200710/184 X-Sequence-Number: 27206 Hi, I am trying to decide between using a temporary table or a stored proc that returns a result set to solve a fairly complex problem, and was wondering if Postres, when it sees a stored proc reference in a SQL, is smart enough to, behind the scenes, create a temporary table with the results of the stored proc such that the stored proc does not get executed multiple times within a single query execution?? Example: suppose I had a stored proc called SP_bob that returns a result set including the column store_no and I wrote the following query: select * from Order_Line as X where not exists (select 1 from SP_bob(parm1, parm2) as Y where X.store_no = Y.store_no) Can I rest assured that the stored proc would only run once, or could it run once for each row in Order_Line?? The only reason I am going down this road is because of the difficulty of using temp tables ( i.e. needing to execute a SQL string). Does anyone know if this requirement may be removed in the near future? -- View this message in context: http://www.nabble.com/using-a-stored-proc-that-returns-a-result-set-in-a-complex-SQL-stmt-tf4628555.html#a13216092 Sent from the PostgreSQL - performance mailing list archive at Nabble.com.