Unbounded Query No Limit (ARCH5061)
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.
Incorrect
Section titled “Incorrect”var orders []Orderdb.Find(&orders) // whole table loaded into memoryreturn ordersCorrect
Section titled “Correct”var orders []Orderdb.Limit(50).Offset(page * 50).Find(&orders)return ordersAdd Limit and pagination to queries that feed a list or response to bound the rows fetched.