"There are many applications for this technology, and once you
start dabbling, your mind will surely run wild with ideas. For
instance, the default MySQL server's slow query log provides only
single second granularity. If you want microsecond control, you'll
have to add the Google patches to get it. That requires a recompile
of the MySQL source, which many administrators would resist. Enter
the MySQL-Proxy, which comes with a lua script to do just that. You
can get the subsecond granularity, and log queries accordingly.
What's great is that you can install it on a running system,
without any big changes. Instead of having your app connect to port
3306, you'll point it to port 4040 of the proxy. But what about
without changing any application code at all? One way would be to
run mysql on a different port, and restart it. Then run the proxy
on port 3306. However, an even better way is to you Linux's
iptables to reroute all incoming connections on port 3306. Take a
look at this link for code snippets to do that:"