... if so, would it be faster?
My use case is a typical LAMP stack that is hosting a REST API. This API is structured in a manner so that I have 10 ( will grow to approx. 50) different queries that will be run with different inputs, and I expect the frequency to be very rapid. I am specifically not asking about result caching of the queries, as I understand enough of that to pursue it separately. I am specifically concerned with the fact that 95% of the application logic will be client side JS, and the high volume of tiny REST requests which will mostly be doing small queries and returning them to the browser to deal with will end up doing a lot of redundant work for each request. If I can use persistant connections, and check APC or memcache for the PDO prepared statement, and re-use it, I would expect to reduce the apache server to mysql server overhead substantially.
I see http://dev.mysql.com/doc/refman/5.1/en/query-cache-operation.html will likely occur in my use case as well, but it would still have the prepare statement being sent for each request.
Nope.
That's interesting question and I spent some good time investigating it.
There is no way to pass a prepared statement between calls.
And, honestly, speed gain is not that great to talk about.
If you're concerned in performance - turn to the queries, not to mere a driver.
It's queries that affect performance, not the way they re called.
errr..
after reading your question more throughly, I didn't change my mind, but there are some things to note
high volume of tiny REST requests which will mostly be doing small queries and returning them to the browser to deal with will end up doing a lot of redundant work for each request.
That's right.
So, consider to reduce that number by sending requests in batches and requesting more info in one. Not because of negligible difference in prepared statements but because of considerable network latency.
I would expect to reduce the apache server to mysql server overhead substantially.
And this one is not.
Looks like you're taking prepared statements wrong and confusing them with query cache.
Even if you manage to get prepared statements to persist between requests, it won't affect whatever apache to mysql interchange - you need to execute every subsequent call to prepared statement, means send request to mysql server. So, the only thing you save on is just query parsing which is blazingly fast nowadays. I mean unnoticeable fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With