Skip to content

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.

def list_users():
return list(User.objects.all()) # could be millions of rows
def list_users(page=0, size=50):
start = page * size
return list(User.objects.all()[start:start + size]) # paginated

Add a [:N] slice or pagination to queries feeding a list/response to bound the result set.