Select Star Over Fetch (ARCH5066)
Esta página aún no está disponible en tu idioma.
Key go.orm.select-star-over-fetch · Severity info · Category orm
Fetching the full entity/all columns when only a few fields are used inflates row width and serialization cost. Use a projection.
Incorrect
Section titled “Incorrect”var users []Userdb.Find(&users) // all columnsfor _, u := range users { fmt.Println(u.Email)}Correct
Section titled “Correct”var emails []stringdb.Model(&User{}).Pluck("email", &emails)Project only the needed fields with Select/Pluck to reduce the column width fetched.