From: Jim Nasby <decibel@decibel.org>
To: Jonah H. Harris <jonah.harris@gmail.com>
Cc: Collin Peters <cadiolis@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Dynamic prepare possible in plpgsql?
Date: Mon, 7 May 2007 11:58:15 -0500
Message-ID: <6960BD9A-8B30-4906-ACA2-7ACF5DAD02C0@decibel.org> (raw)
In-Reply-To: <36e682920705011016u6af5810bv4fc3ad7feb0fbe8e@mail.gmail.com>
References: <df01c91b0704301658r71068bf1jea60b8f6d6c5769c@mail.gmail.com>
<11208.1177980742@sss.pgh.pa.us>
<df01c91b0705010952s4fb5fd5fpd9f4f61ff9673875@mail.gmail.com>
<36e682920705011016u6af5810bv4fc3ad7feb0fbe8e@mail.gmail.com>
On May 1, 2007, at 12:16 PM, Jonah H. Harris wrote:
> On 5/1/07, Collin Peters <cadiolis@gmail.com> 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.
BTW, a good use for a version of EXECUTE that accepted parameters is
the trigger on a partitioned table to direct inserts to the
appropriate partition. Currently, you have to quote_literal(coalesce
(NEW.field, 'NULL')) in the dynamic statement.
--
Jim Nasby jim@nasby.net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)
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: decibel@decibel.org, jonah.harris@gmail.com, cadiolis@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: Dynamic prepare possible in plpgsql?
In-Reply-To: <6960BD9A-8B30-4906-ACA2-7ACF5DAD02C0@decibel.org>
* 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