Re: Pointless PREPAREs/DEALLOCATEs

"David E. Wheeler" <[email protected]> Fri, 3 Dec 2010 10:46:23 -0800
Newsgroups gmane.comp.db.postgresql.dbdpg
Message-ID <[email protected]>
On Dec 3, 2010, at 10:35 AM, Florian Weimer wrote:

> It seems that at least when using bind_param, DBD::Pg performs three
> server round-trips for every execution of a prepared statement
> (PREPARE, EXECUTE, DEALLOCATE).  This has been observed with DBD::Pg
> 2.17.1 (plus the BYTEA patch from r414471) against a PostgreSQL 9.0.1
> server.
> 
> Is this really necessary?  Is there a way to avoid this, without
> disabling server-side prepared statements altogether?

If you use prepare_cached(), it should only do the PREPARE on the first call, and EXECUTE only on subsequent calls. Not sure when it does the DEALLOCATE though; maybe it doesn't?

David