Re: 7.3 Prepared statements

From: Neil Conway <neilc(at)samurai(dot)com>
To: Ericson Smith <eric(at)did-it(dot)com>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: 7.3 Prepared statements
Date: 2002-12-17 16:31:52
Message-ID: 1040142712.456.68.camel@tokyo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

On Tue, 2002-12-17 at 10:19, Ericson Smith wrote:
> 1. What is the lifetime of the plan created?

>From the PREPARE reference page:

Prepared queries are stored locally (in the current backend), and only
exist for the duration of the current database session. When the client
exits, the prepared query is forgotten, and so it must be re-created
before being used again. This also means that a single prepared query
cannot be used by multiple simultaneous database clients; however, each
client can create their own prepared query to use.

> 2. If it is for the session, does it last through persistent connections
> (eg. PHP)

Yes -- but as noted above, relying on a prepared query to exist for a
given connection is tricky. At best, you can write your client in such a
way that whenever it EXECUTEs a query it didn't PREPARE itself, it is
capable of issuing the requisite PREPARE statement if the EXECUTE fails.

Cheers,

Neil
--
Neil Conway <neilc(at)samurai(dot)com> || PGP Key ID: DB3C29FC

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-12-17 16:34:29 Re: prepared statements and analyze in 7.3
Previous Message Jean-Luc Lachance 2002-12-17 16:04:37 Re: ORDER BY random() LIMIT 1 slowness

Browse pgsql-jdbc by date

  From Date Subject
Next Message Anders Hermansen 2002-12-17 16:35:16 [PATCH] NPE in meta data getPrimaryKeys()
Previous Message Ericson Smith 2002-12-17 15:19:43 7.3 Prepared statements