From: Neil Conway <neilc@samurai.com>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: Bojidar Mihajlov <bmihajlov@yahoo.com>
Cc: pgsql-hackers@postgresql.org
Cc: pgsql-odbc@postgresql.org
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections
Date: Tue, 25 Jan 2005 21:19:46 +1100
Message-ID: <41F61D42.50804@samurai.com> (raw)
In-Reply-To: <41F61367.5060807@familyhealth.com.au>
References: <20050125092707.32541.qmail@web50502.mail.yahoo.com>
<41F61367.5060807@familyhealth.com.au>
Christopher Kings-Lynne wrote:
>> I need a mechanism to keep my queries in optimized state so that
>> multiple processes can use them.
>
>
> You should use stored procedures then.
>
> For instance, say you want to keep 'SELECT * FROM table WHERE id=x'
> prepared. You would go:
>
> CREATE OR REPLACE FUNCTION get_table_id(integer) RETURNS SETOF table AS
> 'SELECT * FROM table WHERE id=$1' LANGUAGE SQL;
>
> PostgreSQL will store a prepared version of that statement after its
> first use.
... a prepared version that is local to the backend that invokes the
function, yes (i.e. it will be planned once per backend). So ISTM this
is equivalent functionality to what you can get using PREPARE or the
extended query protocol.
There currently isn't support for prepared queries that span multiple
connections. There has been prior discussion of the topic, so try
searching the pgsql-hackers archive. There are some implementation
issues that require thought (e.g. managing dependencies, storing a
potentially unbounded set of prepared queries in a finite amount of shmem).
-Neil
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: neilc@samurai.com, chriskl@familyhealth.com.au, bmihajlov@yahoo.com, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections
In-Reply-To: <41F61D42.50804@samurai.com>
References: <20050125092707.32541.qmail@web50502.mail.yahoo.com> <41F61367.5060807@familyhealth.com.au> <41F61D42.50804@samurai.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