Large Result Not Chunked (ARCH5062)
Esta página aún no está disponible en tu idioma.
Key go.orm.large-result-not-chunked · Severity info · Category orm
Loading an entire large result set into memory then iterating holds millions of rows at once. Process it with a chunked/streaming API.
Incorrect
Section titled “Incorrect”var users []Userdb.Find(&users)for _, u := range users { process(u)}Correct
Section titled “Correct”db.FindInBatches(&[]User{}, 1000, func(tx *gorm.DB, batch int) error { for _, u := range *tx.Statement.Dest.(*[]User) { process(u) } return nil})Iterate large result sets with a chunked/streaming API like FindInBatches to bound memory use.