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

Re: prepare()

From: "Stuart Cooper" <stuart(dot)cooper(at)gmail(dot)com>
To: "Tom Allison" <tom(at)tacocat(dot)net>
Cc: "General PostgreSQL List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: prepare()
Date: 2007-05-30 00:53:58
Message-ID: 7fc8628a0705291753u34662484wea1da6408b6f3c05@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
> Is there an advantage to using something like $dbh->prepare($sql) if
> the SQL is going to be run once within the scope of the code?  The
> code block may be run many times in a minute as in a function call ---

> while (<>) {
>     insert_something($_);
> }

> Will the prepare statement be cached @ the database even if it's
> destroyed in the code/application?

The pg_prepared_statments view will give you information on prepared statments
currently resident in the database backend. I suggest you run your progam
(with a couple of "Enter to continue" breakpoints in the code) and, in another
session, select from pg_prepared_statements and see if the prepared statement
is still there.

I'll be trying this myself a bit later once I stabilise my system, so
watch this space!

Cheers,
Stuart.

In response to

  • prepare() at 2007-05-29 23:28:14 from Tom Allison

Responses

pgsql-general by date

Next:From: Stuart CooperDate: 2007-05-30 01:17:36
Subject: Re: prepare()
Previous:From: novnovDate: 2007-05-30 00:18:42
Subject: function retuning refcursor, order by ignored?

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