Installation of the plugin is quick and simple, as usual:
script/plugin install http://svn.lightyearsoftware.com/svn/plugins/sql_logging
You're then ready to harness the power! Whilst in development mode, the plugin will add additional details to your logfile and allow you to see what's going on with your queries and where any holdups are occuring.
Rather than re-invent the wheel, i'll suggest reading the original blog post by the author of the plugin for more details.
I also periodically scan through my logs for long queries using a simple cat and grep combo to give me the 20 slowest queries:
cat log/production.log | grep "Completed in" | cut -f3 -d' ' | sort -n -r | head -n 20
Based on this I can then look through my log and identify the slow query and make efforts to improve it.


Leave a reply
You can use Markdown in your comment as well as plain HTML. You can use
<filter:jscode lang="ruby">and</filter:jscode>tags to surround code blocks (supported languages are css, html, javascript and ruby). Your email address will not be published.If your comment doesn’t appear immediately after posting it could have been marked as spam. Don’t worry: we regularly check for and approve incorrectly filtered comments so you shouldn’t have to wait too long for it to be shown.