ActiveRecord - Find in Batch

ActiveRecord::Base#find_in_batches. This lets you iterate over all the records in cursor-like fashion (only retrieving a set number of records at a time into the memory): @Subscription.find_in_batches(batch_size => 100 ) { |subs| subs.each { |s| ... } }@ iterate over all subscriptions in chunks of 100 find_in_batches supports scopes @class Subscription < ActiveRecord::Base scope :expired, :conditions => { :expired => true } end @ @Subscription.expired.find_in_batches(:batch_size => 100 ) { |subs| ... }@ _Disadvantage: _ You can’t specify :order or :limit in the options. Where to use it: Large Dataset, where you need to loop through