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
When using the Query.One method to populate a single row from the database (like below), it would seem to me like the implication is that it will only select a single row by adding a LIMIT 1 to the query. However, it appears to run the full query without a limit and drops all but the first row. This can be quite expensive if you weren't expecting it.
Should Query.One() add a LIMIT 1? If not, I would recommend this be very clearly advertised in the documentation.
q := db.NewQuery("SELECT id, name FROM users ORDER BY id")
// populate the first row into a User struct
err = q.One(&user)
fmt.Println(user.ID, user.Name)
The text was updated successfully, but these errors were encountered:
When using the
Query.One
method to populate a single row from the database (like below), it would seem to me like the implication is that it will only select a single row by adding aLIMIT 1
to the query. However, it appears to run the full query without a limit and drops all but the first row. This can be quite expensive if you weren't expecting it.Should
Query.One()
add aLIMIT 1
? If not, I would recommend this be very clearly advertised in the documentation.The text was updated successfully, but these errors were encountered: