MySQLPerformanceBlog.com made some guides in the article " Prepared Reports ." Peter Zaitsev wrote:
I did a simple test (using SysBench) to see the performance of a simple query (single line selection), using a standard ticket, a prepared statement, and it is served from the query cache. Prepared statements give 2290 queries / sec, which is much better than 2000 with standard ones, but it is still significantly lower than 4470 queries / sec when the results are from the query cache.
It seems that the "overhead" of using prepared statements is that they are 14.5% faster than using direct query execution, at least in this simple test. The relative difference is likely to decrease with a more complex query or a larger set of results.
It seems controversial that prepared queries will be faster, given double server feedback and other factors. There are no details in Peterโs test. In any case, you should run your own tests, because the type of request that you run, as well as your environment and equipment, are definitely important factors.
Regarding Query Cache, in the past it was true that prepared statements were incompatible with query caching results, but this has been changed. See "How Query Cache Works" in the MySQL documentation:
Before MySQL 5.1.17 prepared statements do not use the query cache. Starting from 5.1.17, prepared statements use the query cache under certain conditions, which vary depending on the preparation method: ...
The following describes these conditions. Go read it.
I recommend using prepared statements for SELECT queries. Quoting variables when interpolating them into SQL statements can be effective if you do this sequentially. But even quoting can have some subtle security vulnerabilities, for example. with multibyte character sets (see MySQL Error # 8378 ). In these cases, it is easier to use prepared queries in a safe way.