The Ruby MySQL slow query log parser converts your slow query logs in to a more usable format.
It also adds some interesting information like median and average times.

Here is an example of what the parsed log looks like

1 Queries
Taking 4 seconds to complete
Locking for 0 seconds
Average time: 4, Median time 4
Average lock: 0, Median lock 0

DELETE FROM blah WHERE blah1 >= XXX AND blah2<= XXX;
################################################################################

22 Queries
Taking 3 3 seconds to complete
Locking for 0 0 seconds
Average time: 3, Median time 3
Average lock: 0, Median lock 0

select * from table1 WHERE table1.something = table.something and table1.x = XXX;
################################################################################

This parser was inspired by the perl mysql_slow_log_parser written by Nathanial Hendler.

Any suggestions or additions are more then welcome!
They can be ether emailed to lee (at) kumkee (dot) com or left as a comment here

Usage

You will need to have Ruby installed and set up. To download ruby go to http://www.ruby-lang.org/en/downloads/.

To run the parser on a command line use

ruby SlowQueryLogParser.rb path_to.log [options]

Options

lock - Order by the amount of time a query locked a table.
time - Order by the amount of time a query took to run.

To parse your log ordered by the lock time and have the result output to a file (in Linux / OS X) you would use:

ruby SlowQueryLogParser.rb path_to.log lock > results.txt

Todo

- Parse server info at the top of the log
- Add date / time selection
- XML Output
- Totals information / stats

Download

Version 0.1 Alpha ( 2007 - 06 - 06 )