See the video here: http://www.starrhorne.com/2014/05/19/biggish-data-rails-postgres.html
Once your database hits a few hundred million rows normal ActiveRecord conventions don't work so well.
...you find yourself in a new world. One where calling count() can bring your app to its knees. One where migrations can take all day.
This talk will show you how to work with big datasets in Rails and Postgresql. We'll show how normal conventions break down, and offer practical real-world advice on maintaining performance, doing maintenance, and tuning rails for optimal DB performance.