Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] RQ: Prepared statements used by multiple connections

From: Neil Conway <neilc(at)samurai(dot)com>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: Bojidar Mihajlov <bmihajlov(at)yahoo(dot)com>,pgsql-hackers(at)postgresql(dot)org, pgsql-odbc(at)postgresql(dot)org
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections
Date: 2005-01-25 10:19:46
Message-ID: 41F61D42.50804@samurai.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-odbc
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


In response to

Responses

pgsql-hackers by date

Next:From: ITAGAKI TakahiroDate: 2005-01-25 10:33:40
Subject: Re: WAL: O_DIRECT and multipage-writer
Previous:From: Christopher Kings-LynneDate: 2005-01-25 09:37:43
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections

pgsql-odbc by date

Next:From: Christopher Kings-LynneDate: 2005-01-25 10:36:34
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections
Previous:From: Christopher Kings-LynneDate: 2005-01-25 09:37:43
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group