http://www.cse.iitd.ernet.in/~sbansal/pubs/fast04ppt.pdf
QueryRecorder is a tool for detecting the N+1 queries problem from tests.