Running DB2® maintenance manually

At installation, DB2® automatic maintenance is switched on, which means that DB2® periodically checks to see if it needs to collect new database statistics, so that it can perform the maintenance, adjusting the performance parameters to maximize performance.

This section describes how to perform the DB2® maintenance process on demand, instead of waiting for DB2® to do it according to its automatic maintenance policy. The process is run by the dbrunstats tool which you can run whenever you need to, without stopping DB2® or interrupting its processing.

To run this tool, follow this procedure:
  1. Locate the DB2® tools: see Locating the DB2 tools.
  2. Check that the user who is going to run the procedure has the appropriate rights (see User permissions for running the DB2 tools)
  3. On the DB2 server, open a DB2® shell, as follows:
    UNIX
    Follow these steps:
    1. Issue the command su - db2inst1, or change to the subdirectory sqllib of the home directory of the owner of the DB2® instance (by default db2inst1)
    2. Launch the command . ./db2profile
    Windows
    Select from the Start menu, Programs →; IBM DB2 →; Command Line Tools →; Command Window
  4. Check that the command shell is correctly initialized by issuing the command db2, and checking that the command is recognized.
  5. Issue the command quit to leave the DB2® Processor mode.
  6. From within the shell, browse to the directory where you copied the script.
  7. Run the script:
    UNIX
    dbrunstats.sh database [user [password]]
    Windows
    dbrunstats database [user [password]]
    where:
    database
    The name of the database. The default name is TWS. Supply this value unless you have changed it.
    user
    The DB2® administration user. If this is omitted, the ID of the user running the command will be used.
    password
    The password of the DB2® administration user. If this is omitted, it will be requested interactively.

    The script runs, giving you various messages denoting its progress and successful conclusion. At the end (it is not particularly time-consuming) the database performance parameters have been reset to maximize performance.