While working on performance tuning for one of our clients, we have performed some benchmarks on the various statement types and JDBC options for MySQL. The results turned out to be somewhat interesting, so we are sharing it here :)
useServerPrepStmtswas set to
cachePrepStmtswas set to
The benchmark issued simple select queries, with randomized parameters that return no results. Tests were performed on MySQL 5.0.44, using MySQL Connector/J 5.0.7.
Plain statements are not worth the hassle or the potential SQL-injection security holes. Prepared statements perform significantly better with a combination of
cachePrepStmts=true. And the conventional wisdom of reusing JDBC statements still applies.