Rails allows rapid prototyping and quick releases. You start a new project, and in a few minutes you already have something to show.  Scaffolds, migrations, scopes and models appear very fast. Everybody is happy until long after the release. But then things start to slow down and you turn your attention to logs. Firstly you double-check  that there is no  n+1 queries and everything is preloaded. Later you try to organize things so that only 1 or 2 queries hit the database per http request, maybe offloading user and session handling to in-memory store. Later you offload long operations to background jobs, or maybe even separate applications/scripts. And everything is OK again.

Fast-forward to the point where your user/customer count has multiplied and you start noticing that database load is reflecting user increase. Most possibly there is something with your queries, and some of them may need attention.  You start to log your queries and do some research on database logs. Very soon the list of slowest queries is ready, but amazingly you did not write some of them. Quick grep of log and query is NOT found.  Huh? Is that your super-search gem building a very complex query and running it against raw connection, bypassing activerecord-sql log, at same time assuming you have created index, that he asked you to do in readme-you-never-read? You may never know.

 

http://blog.toggl.com/2013/04/introducing-pg_decorator/