Skip to content

Questions regarding PreparedStatements #1241

Answered by bgrainger
OAguinagalde asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not entirely sure what you mean by "But MySqlConnections are not reusable". MySqlConnection is not a one-time use class; you can reuse an open connection as much as you want (just not simultaneously by two different threads), or even Close and re-Open it.

You'd have to profile its use with your particular database, but my general feeling is that prepared statements in MySQL are not worth it. Yes, you do save a little bit of time from not having to re-parse the SQL when you re-execute the statement. But on the other hand, they're scoped to just one physical database connection. You'd have to prepare each of the n commands your application will use on each of the m concurrent DB connect…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@OAguinagalde
Comment options

Answer selected by OAguinagalde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1240 on November 15, 2022 13:25.