Unbounded Query No Limit (ARCH6061)
Ce contenu n’est pas encore disponible dans votre langue.
Key ruby.orm.unbounded-query-no-limit · Severity info · Category orm
Fetching an entire table with no LIMIT or pagination risks memory blowup on large tables when the result feeds a list or response.
Incorrect
Section titled “Incorrect”def index render json: User.all # whole table into memory and the responseendCorrect
Section titled “Correct”def index render json: User.limit(50).offset(params[:offset].to_i)endAdd limit and pagination to queries that feed a list/response to avoid fetching the whole table.