Zum Inhalt springen

Early Materialization (ARCH5056)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key go.orm.early-materialization · Severity warning · Category orm

Filtering or sorting after materializing the query result moves work that belongs in the database into the application. Push the filter into the query.

var users []User
db.Find(&users)
var active []User
for _, u := range users {
if u.Active {
active = append(active, u)
}
}
var active []User
db.Where("active = ?", true).Find(&active)

Push filtering, ordering, and aggregation into the query with Where/Order instead of doing it in memory.