Unbounded Query No Limit (ARCH2061)
Key python.orm.unbounded-query-no-limit · Severity warning · Category orm
Fetching an entire table with no LIMIT or pagination and feeding it into a list or response risks memory blowup on large tables. Cap the query.
Incorrect
Section titled “Incorrect”def list_users(): return list(User.objects.all()) # could be millions of rowsCorrect
Section titled “Correct”def list_users(page=0, size=50): start = page * size return list(User.objects.all()[start:start + size]) # paginatedAdd a [:N] slice or pagination to queries feeding a list/response to bound the result set.