Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why would I not want to set interpolateParams=true? #413

Closed
rootscity opened this issue Jan 21, 2016 · 2 comments
Closed

Why would I not want to set interpolateParams=true? #413

rootscity opened this issue Jan 21, 2016 · 2 comments

Comments

@rootscity
Copy link

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?

@methane
Copy link
Member

methane commented Jan 22, 2016

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.

@rootscity
Copy link
Author

Thank you for the quick answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant