pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Collin Peters <cadiolis@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Dynamic prepare possible in plpgsql?
Date: Tue, 1 May 2007 09:52:52 -0700
Message-ID: <df01c91b0705010952s4fb5fd5fpd9f4f61ff9673875@mail.gmail.com> (raw)
In-Reply-To: <11208.1177980742@sss.pgh.pa.us>
References: <df01c91b0704301658r71068bf1jea60b8f6d6c5769c@mail.gmail.com>
	<11208.1177980742@sss.pgh.pa.us>

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 <tgl@sss.pgh.pa.us> wrote:
> "Collin Peters" <cadiolis@gmail.com> 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
>



view thread (7+ messages)  latest in thread

Message-ID: <df01c91b0705010952s4fb5fd5fpd9f4f61ff9673875@mail.gmail.com>
Permalink:  ../df01c91b0705010952s4fb5fd5fpd9f4f61ff9673875@mail.gmail.com/
Also on:    postgresql.org/message-id/df01c91b0705010952s4fb5fd5fpd9f4f61ff9673875@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cadiolis@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Dynamic prepare possible in plpgsql?
  In-Reply-To: <df01c91b0705010952s4fb5fd5fpd9f4f61ff9673875@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox