As all good Ruby on Rails programmers know, there are plenty of plugins out there to help you get on with creating your application. Not having to re-invent the wheel for things like tags and pagination can be a huge blessing.
There are also a great deal of plugins that attempt to give developers an idea of how hard Rails is working the database. Plugins like qtrace, query_stats, query_trace and query_analyzer all exist to serve this purpose.
In my experience, though, no one plugin does everything I need. I don’t mind installing each of those listed above, though, as it feels like a very discreet and unix-like mindset. Do one thing and do it well.
To that end, here’s my addition to the array of sql-surveillance-plugins, called Sql Profiler. Here’s how I described it in the README:
SqlProfiler just logs the queries your application makes so that you can pull out a report of the most executed ones, making it a pretty dumb but quick way of profiling your code and finding the initial places to start caching. It also logs the number of rows returned by each query, which is handy for finding memory leaks, as I discovered recently when a custom finder I’d thought was intelligent (as it made extensive use of :include to fetch in all the required associations) turned out to be lacking a simple ‘group by’ statement, resulting in thousands upon thousands of rows being returned.
Get it here - http://rubyforge.org/projects/suttree/ - or install it directly into your application like so:
script/plugin install http://suttree.rubyforge.org/svn/sql_profiler/
Feedback, bugs, suggestions - they’re all welcome!
Post a Comment