Aller au contenu

Unbounded Query No Limit (ARCH5061)

Ce contenu n’est pas encore disponible dans votre langue.

Key go.orm.unbounded-query-no-limit · Severity warning · Category orm

Fetching an entire table with no LIMIT or pagination risks memory blowup on large tables. Paginate the result.

var orders []Order
db.Find(&orders) // whole table loaded into memory
return orders
var orders []Order
db.Limit(50).Offset(page * 50).Find(&orders)
return orders

Add Limit and pagination to queries that feed a list or response to bound the rows fetched.