Detecting duplicate queries


I noticed in my logs that I'd be doing some duplicate queries and I'd
like to implement a system to warn me of duplicates in the future. I'm
fairly new to the Rails framework, so I'm not able to make an informed
decision as how to best implement this.

ActiveRecord Observers stood out as the most obvious candidate, yet at
closer look they don't seem able to help. I need some hooks for a
per-requests basis, not per-module.

I assume that using a plugin I am able to override AbstractAdapter#log?
(I've never written a plugin). So I suppose I'm looking for the best
place to insert my request start/end hooks before I go off writing

Of course, I'd much prefer someone to point me in the direction of some
code that already does all of this :wink: