You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From what I've read it seems that each database/sql Query / Exec with args that I issue is prepared, executed, and closed on the server, resulting in 3 round-trips. And I can avoid that behavior by setting interpolateParams=true. Are there any downsides to setting interpolateParams to true? If I don't set it and a prepared statement is created behind the scenes as a result of issuing a Query / Exec, and later another Query / Exec with the same text is issued, does the driver remember the earlier-prepared statement? As far as I can tell it doesn't, and another Prepare call is made to the server, so it seems that the prepared statement that is created behind the scenes as a result of issuing a Query / Exec is single-use only, which seems wasteful.
Also, I'm thinking that if I've set interpolateParams=true and I want to create and re-use a prepared statement, I can still call Prepare in my code to create the prepared statement.
Am I looking at this correctly?
The text was updated successfully, but these errors were encountered:
You're right. interpolateParams=true doesn't affect to explicit DB.Prepare and Stmt.Exec.
If you meets some trouble relating to interpolateParams, you can avoid it by using explicit prepared statement.
So there is no downside when you know what "interpolateParams" means.
I'm sorry for the newbie question.
From what I've read it seems that each database/sql Query / Exec with args that I issue is prepared, executed, and closed on the server, resulting in 3 round-trips. And I can avoid that behavior by setting interpolateParams=true. Are there any downsides to setting interpolateParams to true? If I don't set it and a prepared statement is created behind the scenes as a result of issuing a Query / Exec, and later another Query / Exec with the same text is issued, does the driver remember the earlier-prepared statement? As far as I can tell it doesn't, and another Prepare call is made to the server, so it seems that the prepared statement that is created behind the scenes as a result of issuing a Query / Exec is single-use only, which seems wasteful.
Also, I'm thinking that if I've set interpolateParams=true and I want to create and re-use a prepared statement, I can still call Prepare in my code to create the prepared statement.
Am I looking at this correctly?
The text was updated successfully, but these errors were encountered: