Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 235D19FA5DD for ; Tue, 1 May 2007 13:52:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 65893-07 for ; Tue, 1 May 2007 13:52:52 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.230]) by postgresql.org (Postfix) with ESMTP id AB0F09FA521 for ; Tue, 1 May 2007 13:52:53 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id s1so1648831nze for ; Tue, 01 May 2007 09:52:52 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=QsWonbXi5V04XzslTIdJwBAXAg0VlBlzru2JAPTjRLb5vOxDWWdrxAk1jxBVsDl4JuTqbhz8TQBxl5vnVb/XyWCvj6yGKYpecAj3y+8uYKmXgMGVVOylqZwrwmuo3nlz6/FsTct8pez1Isdrj+NQM/mAUBcyd0xYmKlDCGtJe0k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GYpJkmtu+kM6uDvQJbprR9k+w84FPfAG6qIh1EvkggdKwZS76Ijd5nLYW0ineDsvzui5Rau7y5hf0NcJCQx3tFMDq/OuW4mbct0PKnkubhzxyJwUmZeXtFru8bHf7k5T6L3r1oxTe2cOTp78zdVN3vvdRqpzRAZv8jBI2TlpWio= Received: by 10.114.95.1 with SMTP id s1mr2441981wab.1178038372610; Tue, 01 May 2007 09:52:52 -0700 (PDT) Received: by 10.114.37.3 with HTTP; Tue, 1 May 2007 09:52:52 -0700 (PDT) Message-ID: Date: Tue, 1 May 2007 09:52:52 -0700 From: "Collin Peters" To: "Tom Lane" Subject: Re: Dynamic prepare possible in plpgsql? Cc: pgsql-sql@postgresql.org In-Reply-To: <11208.1177980742@sss.pgh.pa.us> 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> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/1 X-Sequence-Number: 28282 I have a plpgsql function which is doing a loop over one table of user data and then inserting that data in various tables. Example: loop over user table (temp data) insert into users1 table insert into users2 table etc.... end loop 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. Collin On 4/30/07, Tom Lane wrote: > "Collin Peters" writes: > > Is it possible to have a dynamic PREPARE statement in plpgsql? > > Well, you could use plpgsql's EXECUTE to run SQL PREPARE and EXECUTE > commands, but it seems awfully brute-force. What do you really need > to accomplish here? > > regards, tom lane >