Quanto!

A project to profile your queries as they hit a mysql server.

The mysql-proxy "sits between your client and MySQL server(s) and can monitor, analyse or transform their communication".

For this project we added a "fingerprint" comment to the start of each query as it was generated in our application. The application is then configured to point at a mysql-proxy rather then the mysql-server. The proxy is running the quanto-collector.lua script. Using the fingerprint as a key, Quanto stores aggregate query statistics, such as timing information, call counts, rows returned, etc. The fingerprint also stores information describing the line and module that generated the query.

You can use the mysql client to access the proxy directly and view the statistics with the "show stats" command, and zero them again with the "clear stats" command.

The project also has some CGI written in perl and using a tiny amount of JQuery to retrieve the stats and display the results nicely.

This gives you feedback about the performance of your application while it's running. You can spot problems like slow queries (timed in milliseconds), queries that return too many rows, or queries running more often than you expect. Even without performance problems, you can see where you should concentrate your efforts if you want to speed things up.

Download the project from github here.

Screenshots

Here's one. Here's another showing an "expanded" query.

Or you can take a look at some sample output yourself.

Presentation

Here's the slides for a presentation t0m (mail) did on Quanto, or they're available in source form.

License

All this stuff is licensed under the same terms as perl.