May
08
2013
May
08
2013
We are constantly looking for great minds to join and enrich our team. Please upload your CV to let us know about your talents.
Upload your CVNov
11
2007
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 :)
| Type | Reused | Server-side | Cached | Duration | Relative |
|---|---|---|---|---|---|
| Plain | n/a | n/a | n/a | 283 | 100% |
| Prepared | - | - | - | 328 | 116% |
| Prepared | Y | - | - | 267 | 94% |
| Prepared | - | - | Y | 302 | 107% |
| Prepared | - | Y | - | 433 | 153% |
| Prepared | - | Y | Y | 243 | 86% |
| Prepared | Y | Y | Y | 216 | 76% |
useServerPrepStmts was set to true.cachePrepStmts was set to true.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 useServerPrepStmts=true and cachePrepStmts=true. And the conventional wisdom of reusing JDBC statements still applies.
EU Edge LLC
24 Tölgyfa street
1027 Budapest, Hungary
Tel.: +36 1 438 6337
Fax: +36 1 438 6336
email:
Comments
very helpful information to campare whether to use prepared statements or not
Perfect, just what I was looking for, thanks.
Nice round-up, but I'd like to see a lot more variation in your queries. How does it fair with insert, update, delete, etc. statements? Also, how many times did you execute your queries? That sort of stuff...
Hi,
I know my comment is very old as you have posted this blog long back. Just I want to say it is very useful tips to get better performance in project. Many developer used to use PreparedStatment without knowing complete things behind it.
Thanks for your compare table.
Thanks again for your this blog.
Binod Suman
Add new comment