Re: Cached Query Plans

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "PFC" <lists(at)peufeu(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cached Query Plans
Date: 2008-04-11 23:35:15
Message-ID: 87lk3kdky4.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"PFC" <lists(at)peufeu(dot)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!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ron Mayer 2008-04-12 00:08:21 Re: Index AM change proposals, redux
Previous Message Tom Lane 2008-04-11 23:17:27 Re: Cached Query Plans