Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Analyze Rails development log for SQL generated and give some overall statistics about number of queries generated and how fast they run.
branch: master

Cleaned up trailing spaces.

latest commit 15b29c30e9
David Dai authored
Failed to load latest commit information.


General Info

rails_log_stat.rb parses a given Rails development log file and builds an in-memory data structure to provide various statistics about your Rails app.

The two primary statistics that the program currenting provides are:

  • SQL total time span and query calls on a per model per request basis.

  • Rendered time break down on a per template per request basis.

rails_log_stat.rb is a very easy way to gain some perspectives about the bottlenecks of your Rails application (most of the time is due to slow SQLs). Although, log files should not be taken as an absolute truth about your application's performance, it does provide a fairly good relative comparison. Personally, I found it quite helpful to start out my optimization process by spotting out big offending queries and eliminating them, and rails_log_stat.rb will help you find those slow queries and lagging renders a lot faster.


Tail your Rails development log

ruby rails_log_stat.rb /path/to/your/development.log 'tail +0 -f'

Note: 'tail +0 -f' is optional and is used by default (it pipes all contents in the log file to the analyzer and then streams the new incoming tails). After running this command just run your App as you normally would w/ SQL log turned on. Or, you can hop to problematic area and run through some scenarios. After you are satisfied, you should come back to the log analyzer and look at your statistics.


l  => show a listing of requests the analyzer have collected.

The the request naming convention is: ControllerName#action [HTTP_METHOD]

r REQUEST_NAME  => show rendered stats
s REQUEST_NAME  => show SQL stats


Alternatively you can use cat to pipe an existing log file into the analyzer.

ruby rails_log_stat.rb /path/to/your/development.log cat


  • Identify the overall slowest queries

  • Identify the overall slowest renders

  • A way to display collected Rails request completion stats.

  • Other output formats

Copyright David Dai.

Something went wrong with that request. Please try again.