The query execution methods below issue exactly the same (amount of 3) queries in DB which is fine and understandable - see below. However, what I want to know is, as far as Go goes is there a real difference between two as in memory, cpu, cache, connection usages so on?
Queries
2020-02-22T12:29:23.858393Z 41 Prepare SELECT id, uuid, name FROM users WHERE id = ?
2020-02-22T12:29:23.859601Z 41 Execute SELECT id, uuid, name FROM users WHERE id = 1
2020-02-22T12:29:23.861607Z 41 Close stmt
Methods
func Select1(query string, args ...interface{}) (*sql.Row, error) {
stmt, err := DB.Prepare(query)
if err != nil {
return nil, err
}
defer stmt.Close()
return stmt.QueryRow(args...), nil
}
func Select2(query string, args ...interface{}) *sql.Row {
return DB.QueryRow(query, args...)
}