Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id BBB669FB781 for ; Mon, 19 Mar 2007 07:18:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 20694-06 for ; Mon, 19 Mar 2007 07:18:11 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by postgresql.org (Postfix) with ESMTP id 1F3F59FB765 for ; Mon, 19 Mar 2007 07:18:10 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id k3so1140332ugf for ; Mon, 19 Mar 2007 03:18:09 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id:from; b=Dj3x3Wjuj/BqJm8YD9MKrA9OIaZCIhvi7gP/sRkJXvbxjOzKVPrb5qN/MsR4NS6LQcjb5hsNkv2n6yWtFnx7HFoAIWIbIAvPOCrhsjcTIsx3TIj73yAS5cIG2W66BKZn53QWsOFd6u2VXVJzu4NtdRxkAGp+4UB66eMt01HbBqc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id:from; b=E+div96FBD84eFKQLKpFUwDwI/WXNDX1kdaUHL5wmr+MDCFeGr9rh468aRzuZm5jINpnSfGldY+6WNg9UvfIKa8ti1/6WDq93n5mchqJ/RzKwaOMUu7raLNOHM4d/QGLfeFuiGqHzfSAZy9ba7TN66wZr5IRVt1UsYXAEqWrs7k= Received: by 10.67.117.18 with SMTP id u18mr9590957ugm.1174299489607; Mon, 19 Mar 2007 03:18:09 -0700 (PDT) Received: from ?192.168.128.42? ( [62.94.42.33]) by mx.google.com with ESMTP id p32sm4823433ugc.2007.03.19.03.18.08; Mon, 19 Mar 2007 03:18:09 -0700 (PDT) To: Tom Lane Subject: Re: function call vs staright query Date: Mon, 19 Mar 2007 11:18:55 +0100 User-Agent: KMail/1.9.5 Cc: pgsql-performance@postgresql.org References: <200703180750.54703.Vincenzo.Romano@gmail.com> <200703180812.49164.Vincenzo.Romano@gmail.com> <21145.1174277261@sss.pgh.pa.us> In-Reply-To: <21145.1174277261@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200703191118.55765.Vincenzo.Romano@gmail.com> From: Vincenzo Romano X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/273 X-Sequence-Number: 23678 On Monday 19 March 2007 05:07 Tom Lane wrote: > Vincenzo Romano writes: > > How can I delay the query planner decisions until the actual query is to > > be done inside the function body? > > Use plpgsql's EXECUTE. AFAIR there is no way in a SQL-language function. > > regards, tom lane The body of a function is *always* treated by the planner as if it were a dynamically created query. The fact we all use the "$$"s (or also the 's) around the function body tells it all. The PREPARE requires every session to do it upon connections, because prepared statements are managed on a per-session basis. What I don't understand is why the planner gets passed by during those queries while it is at full steam during the "normal" queries. But this could be due to my ignorance! :-) -- Vincenzo Romano ---- Maybe Computers will never become as intelligent as Humans. For sure they won't ever become so stupid. [VR-1987]