Re: prepare() - Mailing list pgsql-general

From Stuart Cooper
Subject Re: prepare()
Date
Msg-id 7fc8628a0705291753u34662484wea1da6408b6f3c05@mail.gmail.com
Whole thread Raw
In response to prepare()  (Tom Allison <tom@tacocat.net>)
Responses Re: prepare()
List 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.

pgsql-general by date:

Previous
From: novnov
Date:
Subject: function retuning refcursor, order by ignored?
Next
From: "Stuart Cooper"
Date:
Subject: Re: prepare()