Hi,

With prepared statements being all well and good, how do I know if the query
has not yet been prepared in the backend?  Or is this simply a situation
where I can't win?

eg. Say I have a web page that does a humungous query.  I would like to have
that query prepared, say, for speed.  However, I can't tell if that backend
has had that query prepared or not.  Is there any way around this?

Chris


Fri, 10 Jan 2003 11:48:28 +0800
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Prepared statements question
I guess I should just use a stored procedure...

Chris

> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Christopher
> Kings-Lynne
> Sent: Friday, 10 January 2003 11:48 AM
> To: Hackers
> Subject: [HACKERS] Prepared statements question
> 
> 
> Hi,
> 
> With prepared statements being all well and good, how do I know 
> if the query
> has not yet been prepared in the backend?  Or is this simply a situation
> where I can't win?
> 
> eg. Say I have a web page that does a humungous query.  I would 
> like to have
> that query prepared, say, for speed.  However, I can't tell if 
> that backend
> has had that query prepared or not.  Is there any way around this?
> 
> Chris
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 


Fri, 10 Jan 2003 12:02:40 +0800
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Re: Prepared statements question
On Thu, 2003-01-09 at 22:48, Christopher Kings-Lynne wrote:
> With prepared statements being all well and good, how do I know if the query
> has not yet been prepared in the backend?  Or is this simply a situation
> where I can't win?

Try the EXECUTE; if it fails, run the PREPARE and then rerun the
EXECUTE.

It would be pretty trivial to add a function that checks if a query with
a given name has already been prepared -- is that worth doing?

Cheers,

Neil


09 Jan 2003 23:50:41 -0500
Neil Conway <neilc@samurai.com>
Re: Prepared statements question
Neil Conway wrote:
> On Thu, 2003-01-09 at 22:48, Christopher Kings-Lynne wrote:
> > With prepared statements being all well and good, how do I know if the query
> > has not yet been prepared in the backend?  Or is this simply a situation
> > where I can't win?
> 
> Try the EXECUTE; if it fails, run the PREPARE and then rerun the
> EXECUTE.

Erm...won't the failed EXECUTE boot you out of the middle of a
transaction?  The documentation doesn't make it clear what happens in
that case, and I don't have 7.3.x running to check for myself...



-- 
Kevin Brown					      kevin@sysexperts.com

Sun, 12 Jan 2003 19:12:41 -0800
Kevin Brown <kevin@sysexperts.com>
Re: Prepared statements question
OK, how about a backend function called 'is_prepared(name)'?

Chris

> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Kevin Brown
> Sent: Monday, 13 January 2003 11:13 AM
> To: PostgreSQL Hackers
> Subject: Re: [HACKERS] Prepared statements question
> 
> 
> Neil Conway wrote:
> > On Thu, 2003-01-09 at 22:48, Christopher Kings-Lynne wrote:
> > > With prepared statements being all well and good, how do I 
> know if the query
> > > has not yet been prepared in the backend?  Or is this simply 
> a situation
> > > where I can't win?
> > 
> > Try the EXECUTE; if it fails, run the PREPARE and then rerun the
> > EXECUTE.
> 
> Erm...won't the failed EXECUTE boot you out of the middle of a
> transaction?  The documentation doesn't make it clear what happens in
> that case, and I don't have 7.3.x running to check for myself...
> 
> 
> 
> -- 
> Kevin Brown					      kevin@sysexperts.com
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 


Mon, 13 Jan 2003 11:23:58 +0800
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Re: Prepared statements question