db2top -R

Today’s command line option is -R. In this post, we will look at how you can use the -R option to perform a reset of the snapshot when db2top is started.

First, let’s look at how things work when you don’t specify the -R option. When db2top starts, it turns on the monitoring switches it needs but these are local to db2top itself. Any activity that occurred before db2top started would not be counted if the monitoring switches were off prior to starting db2top. So to demonstrate the difference that the -R option makes, we’re going to turn on database manager-level monitoring switches and run some work prior to starting db2top.

For this simple example of db2top’s behavior when -R is not specified, we’ll turn on a database manager configuration parameter to collect snapshot monitor information for bufferpools and then run a simple query to give the snapshot monitor some bufferpool activity to monitor (we are assuming no other work is running):

db2stop
db2 update dbm cfg using dft_mon_bufpool on
db2start
db2 connect to sample
db2 "select count(*) from syscat.tables"

If we now start db2top with the -k option and press the ‘t’ key to look at the Tablespaces screen, we get something like the following:

db2top Tablespaces screen when -R not used

Notice that we have some non-zero values for Actual l_reads for the SYSCATSPACE table space. If we were to instead launch db2top with the -R option, like this:

db2top -d sample -k -R

db2top will perform a reset of the snapshot when it starts and the Tablespaces screen will now show nothing but zeros:

db2top Tablespaces page when -R used

I would like to thank Tao Wang for answering my questions on the -R option for today’s post. I highly recommend the developerWorks article on db2top that Tao Wang wrote with Shen Li.