find_each

AnyMode.all.each do |r|
  # inefficient
  #  will instantiate all the objects at once.
end

AnyModel.find_each do |r|
  # efficient
  # work with the records in batches(batch_size:), thereby greatly reducing memory consumption
end

Reference

results matching ""

    No results matching ""