Introducing each_in_batches
Performance Measured and Tuned Batch Processing of Records with Blocks in Rails. EachInBatches (Originally BolingForBatches)
NOTE: I am resurrecting this code because I still have this recurring need, and Rail’s native batching doesn’t cut mustard.
It is some of my most ancient code, and it isn’t pretty, but I hope to improve it over time.
I often need to execute really large computations on really large data sets. I usually end up writing a rake task to do it, which calls methods in my models.