Case

You want to check and update db2 statistics of an SAP System.

Solution

1) Find last statistics run of table for example T000. Execute following command as db2<sid>:

db2 “select STATS_TIME from syscat.tables where tabname=’T000′”

2) Execute runstat:

At first find db-owner:

db2 “select tabschema, tabname from syscat.tables where tabname like ‘%USR02%'”

If it yields SAPSR3, execute following command:

db2 “runstats on table SAPR3.T000 with DISTRIBUTION and detailed indexes all”

3) If you want to to run statistics for all table use dmdb6srp tool

dmdb6srp -n <SID> -t ALL