Is it possible to save a prepared PDO report in PHP / Mysql / APC / Memcache for reuse?

... if so, would it be faster? My use case is a typical LAMP stack that hosts the REST API. This API is structured in such a way that I will have 10 (up about 50) different requests that will be executed with different inputs, and I expect the frequency to be very fast. I am not specifically asking about query result caching as I understand it enough to pursue it separately. I am particularly concerned about the fact that 95% of the application logic will be client-side JS, and a large volume of tiny REST requests that will basically make small requests and return them to the browser to work, end up with redundant work for each request. If I can use persistent connections and check APC or memcache for a prepared PDO statement and reuse it, I would expect,which will greatly reduce the apache server overhead on the mysql server.
I see http://dev.mysql.com/doc/refman/5.1/en/query-cache-operation.html will most likely be in my use case as well, but it will still have a prepare statement for every request ...

+3


source to share


1 answer


Nope.
This is an interesting question and I spent some time researching it.
Cannot pass prepared expression between calls.

And to be honest, the increase in speed isn't all that useful to say.

If you are interested in performance, refer to queries , not a simple driver.
It asks what is affecting performance, not how they are called.

uh ..
after reading your question in more detail, I haven't changed my mind, but there are some things to note



a large volume of tiny REST requests that will basically do small requests and return them to the browser to deal with this will end up doing a lot of redundant work for each request.

It is right. So, consider reducing that number by sending requests in batches and requesting more information in one. Not because of a slight difference in prepared operations, but because of significant network latency .

I would guess to significantly reduce the apache server down to the mysql server level.

And this is not.
It looks like you are doing prepared statements wrong and confusing them with the request cache.
Even if you manage to get prepared statements to continue between queries, it won't affect apache to exchange mysql - you need to execute every subsequent prepared statement call, then send a query to the mysql server. So the only thing you keep is just parsing the queries, which is very fast these days. I mean, imperceptibly fast.

+4


source







All Articles