This is a simple rails log analyzer. The initial goal is to
identify SQL queries that could be optimized or find queries that are being
called more often than they should be.
In its current state it is little more than simple regexes. My goal, however is
to build more useful tools on top of it. I’ve added it to a git repository to
allow anyone to make edits and improvements.
It’s not really ready for prime-time (for instance, it doesn’t work well
with log colorization), but I have found it useful so I thought I would share
it. If nothing else it could save someone else 10 minutes to write
a similar script.
What it does
Right now all this does is read a log file and extract SQL “SELECT” statements
and organize them by the amount of time they take. It will also show a summary
of the number of queries called to load each model.
How to get it
git clone \
How to use it
The typical work flow looks like this:
# hit the URL of the page we want to profile, run the rake task, etc
ruby bin/query_log_analyzer.rb log/development.log
- Deal with the colorization of the logs
- Update the code to not be so SELECT centric. Support other types of queries
- Be smarter about each request’s individual queries
I’ve placed this in a git repository, so feel free to submit any patches and
I’ll integrate them into this master.