Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 65FE89FBD23 for ; Wed, 2 May 2007 12:53:18 -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 76758-07-2 for ; Wed, 2 May 2007 12:53:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.235]) by postgresql.org (Postfix) with ESMTP id 158BA9FBD1C for ; Wed, 2 May 2007 12:53:14 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id s1so187323nze for ; Wed, 02 May 2007 08:53:14 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=BAM7okW58pNuWO9YM3k7AdHFVcJ+27wNH2V1WJiDwVAGRdndMb1DrKNhyoobGido0BcqtdNdiO72jJxFw2BBH62x5VqDFipkUnJfr54bnfwsUF2r0y07gber12LOjlmtY374fcYQfJ4BqgJAhgWCcxq4OMDaIwAW2p22Lf+o32c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=jfGLw2VulhFHcVaIC1Vr3Tm90CTGvz4HUuB5lhH4lQHdXDfW5LobBI33MM5bzjE/4heobufIh0B5xL5FlqF8D5HR+LsB8ssXLazuKmSILJdRVJMK0ImFLJ+MiGtzyRqJcv9aCOCEkFy451oWgCovnLtB1DX31uLY3IhzZRAY8Ww= Received: by 10.115.74.1 with SMTP id b1mr261033wal.1178121193612; Wed, 02 May 2007 08:53:13 -0700 (PDT) Received: by 10.114.37.3 with HTTP; Wed, 2 May 2007 08:53:13 -0700 (PDT) Message-ID: Date: Wed, 2 May 2007 08:53:13 -0700 From: "Collin Peters" To: pgsql-sql@postgresql.org Subject: Re: Dynamic prepare possible in plpgsql? In-Reply-To: <36e682920705011016u6af5810bv4fc3ad7feb0fbe8e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <11208.1177980742@sss.pgh.pa.us> <36e682920705011016u6af5810bv4fc3ad7feb0fbe8e@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/6 X-Sequence-Number: 28287 So if I have an INSERT inside a LOOP in a plpgsql function, it is only prepared once? Regards, Collin On 5/1/07, Jonah H. Harris wrote: > On 5/1/07, Collin Peters wrote: > > Is it faster to use PREPARE for the various INSERT statements inside a > > plpgsql function? Perhaps I am wrong and it does its PREPARE work > > when the function is parsed. > > IIRC, PLpgSQL automagically prepares each statement behind the scenes > on the first use. > > > -- > Jonah H. Harris, Software Architect | phone: 732.331.1324 > EnterpriseDB Corporation | fax: 732.331.1301 > 33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com > Iselin, New Jersey 08830 | http://www.enterprisedb.com/ >