Re: Cached Query Plans - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: Cached Query Plans
Date
Msg-id 87lk3kdky4.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: Cached Query Plans  (PFC <lists@peufeu.com>)
Responses Re: Cached Query Plans  (PFC <lists@peufeu.com>)
List pgsql-hackers
"PFC" <lists@peufeu.com> writes:

>     But, using prepared statements with persistent connections is messy,
> because you never know if the connection is new or not, if it contains  already
> prepared statements or not, you'd have to maintain a list of those  statements
> (named) for every query in your application, and when someone  changes a query,
> it's a mess, not to mention queries generated by the ORM  like Rails etc.

Well if you're caching per-connection then it doesn't really matter whether
you do it on the client side or the server side, it's pretty much exactly the
same problem.

Unsurprisingly most drivers do precisely what you're describing. In Perl DBI
for example you just change $dbh->prepare("") into $dbh->prepare_cached("")
and it does exactly what you want. I would expect the PHP drivers to have
something equivalent.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's Slony Replication
support!


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Cached Query Plans
Next
From: Ron Mayer
Date:
Subject: Re: Index AM change proposals, redux