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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-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

Browse pgsql-hackers by date

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

Browse pgsql-odbc by date

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