Re: 7.3 Prepared statements - Mailing list pgsql-general

From Neil Conway
Subject Re: 7.3 Prepared statements
Date
Msg-id 1040142712.456.68.camel@tokyo
Whole thread Raw
In response to 7.3 Prepared statements  (Ericson Smith <eric@did-it.com>)
Responses Re: 7.3 Prepared statements
List pgsql-general
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@samurai.com> || PGP Key ID: DB3C29FC




pgsql-general by date:

Previous
From: Jean-Luc Lachance
Date:
Subject: Re: ORDER BY random() LIMIT 1 slowness
Next
From: Neil Conway
Date:
Subject: Re: prepared statements and analyze in 7.3