Home  |  Linux  | Mysql  | PHP  | XML
Date:Tue Aug  2 11:23:59 2011
Subject:Re: [PDO] Client side cache for prepared queries
Reading this, I think I should add some precisions :

On Tue, Aug 2, 2011 at 11:42 AM, Goran Miskovic <schkovich@gmail.com> wrote:
> Beginning with MySQL 5.1.17, prepared statements use the query cache under
> certain conditions, which differ depending on the preparation method.

You (and the mysql documentation) are speaking about "server side
result cache" (albeit they wrote query cache), here I'm speaking of
"client side prepared query cache" in its strict sense. I'll try to
make the difference clear here :

* Caching the prepared query aimed to reuse memory structure and
execution plan from previous prepared query.
* Caching the prepared query is independent of values, we only speak
here of the prepared query not the executed query.
* Caching the prepared query should be implemented client side to
avoid one round trip.
* The aim of the caching here is to reuse a prepared query, not its result.

Use case :
A website, like any other, have, say, a request to fetch the content
of a post and its comments, the query is executed once per post page,
so a prepared query here is almost useless (Good to prevent injection,
bad cause of an additional RTT to the sql server)

If the client does prepared query cache, in this case, the RTT needed
to tell the serveur to create the query is done only once, and each
following pages that reuse the same SQL connection will got a cache
hit doing the pdo::prepare, economising one RTT and the query plan
building.

Am I clear ? or not ? Wrong ? or not ?

--
Julien Palard
Navigate in group php.pdo at sever news.php.net
Previous Next





  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.