Named parameters, caching and PDO?

If you're using PDO_MySQL, it rewrites prepared statements into raw SQL on its own before the server even sees them, unless you set PDO::ATTR_EMULATE_PREPARES to false.

– Karim Dec 19 '08 at 14:04 @Karim: Yes, pretty much. The default's there to make it work with MySQL 4.x. On top of no performance gains, PDO's rewriter is pretty buggy and doesn't handle edge cases well (it broke my code a few times until I learned to turn it off).

– flussence Jan 29 '09 at 20:18.

It should be recognized as the same statement since the caching is done after the query parameters are replaced by values.

Oh okay. I was under the impression that parameterization is useful for performance because caching can be done without worrying about the actual values that are part of the query. But it sounds like you're saying that caching is done with the given values.

– Karim Dec 19 '08 at 14:08.

PDO has no cache - MySql does. And yes, it will cache the "final" query in the query cache. Not only that, but if you use use the same prepared statements multiple times, you will gain an additional speed increase, because MySql can cache the query execution plan for that statement.

– Karim Dec 19 '08 at 14:05 No, you need to hold on to the prepared statement, to re-use it. But you can call it multiple times, binding different values each time, and get a slight benefit from that. – troelskn Dec 19 '08 at 17:24.

I'm not sure how PDO handles named parameters but if it uses MySQL prepared statements then you will need to use MySQL 5.1.17 or later if you want it to use the query cache. MySQL Query Cache Before MySQL 5.1.17, prepared statements do not use the query cache. Beginning with 5.1.17, prepared statements use the query cache under certain conditions, which differ depending on the preparation method.

Manually quote the parameters. Supports one style but not the other.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions