Everyone who runs a Linux server knows the top command for process monitoring. The mytop utility does the same thing, but for a MySQL server.

mytop is only an apt-get away:
sudo apt-get install mytop

The basic command for running mytop is as follows:
mytop -u username -p password -d databasename

Some other useful arguments include -s (time in seconds before refreshing the display), -P (specify a non-standard MySQL port to connect to), and -h (connect to a remote host). If you don’t want to have to remember your options, you can create a ~/.mytop file to store arguments in this format:

The mytop display is split into two sections. The first few lines show the hostname, server version, uptime, queries per second (qps) overall, current qps, number of threads, and a lot more. The lower part lists all the threads and their current query.

mytop in action

Press the q key to quit mytop.

I watched mytop on my own server for a while and found that the WP-Cache plugin Tombuntu runs leaves the MySQL server without much to do. But when a dynamic page is served it causes several queries. If you need to know what your database server is doing, mytop is an easy way to find out.

Related Posts