-
Notifications
You must be signed in to change notification settings - Fork 7
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
back: Investigate the need for db.Prepare usage and add issues as needed #74
Comments
AC
|
The idiomatic ways to form queries are listed in the Go Database/SQL Tutorial.
I have made queries that are used once then closed. That means the second way (using
I use the third case to set the
As of PR #83, I am using the following which seems fine: _, err := s.db.Exec(
"UPDATE user SET deleted_at = ? WHERE user_id = ?",
time.Now(),
sid,
) I also use the fourth case where queries return single rows. Those queries would use a shortcut:
@daved I believe I'm overusing the If you agree, I can make a new issue to get those queries converted. |
Please review http://go-database-sql.org/prepared.html#avoiding-prepared-statements, along with the linked article (https://orangematter.solarwinds.com/2014/11/19/analyzing-prepared-statement-performance/), and ping me via Slack to setup a chat to discuss this further. |
I've read the section on "Avoiding Prepared Statements" in go-database-sql.org several times. I realized during my last reading that
So, how does one execute a query without preparing the statements? It requires more steps:
The second article at orangematter.solarwinds.com says there's a case for taking the extra steps the write plaintext query executions:
The simple queries in question were of the form The trade off here is reduction to database load vs. writing more lines of code to avoiding preparing statements. And even if we did write extra code, will it work? Does our Go sql driver even support plaintext query execution? I'll send a ping on Slack to discuss further. |
For example, in
back/internal/usersvc/internal/userdb/qryuser.go
The text was updated successfully, but these errors were encountered: