.all.each is highly inefficient with many rows

According to http://guides.rubyonrails.org/active_record_querying.html, chapter 1.3, you should never use .all.each when iterating over the whole table.
Merge pull request #1438 from prasselpikachu/patch-1

.all.each is highly inefficient with many rows