Thanks - unfortunately we do not have the funds to employ a Database Admin for a single application.
After a lot of reading and experimenting I have found that the following works for us (YMMV):
REM ===============================================================
REM -- DOORS NEXT (RM)
db2 CONNECT TO rm USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM ===============================================================
REM -- Jazz Team Server (JTS)
db2 CONNECT TO jts USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM ===============================================================
REM -- Engineering Test Manager (QM)
db2 CONNECT TO qm USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM ===============================================================
REM -- Engineering Workflow Management (CCM)
db2 CONNECT TO ccm USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM ===============================================================
REM -- Data Collection Component (DCC)
db2 CONNECT TO dcc USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM Lifecycle Query Engine (LQE)
db2 CONNECT TO lqe USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM LDX
db2 CONNECT TO ldx USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM ===============================================================
REM -- Data Warehouse (DW)
db2 CONNECT TO dw USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
db2 reorgchk update statistics on table all
REM ===============================================================
REM -- Global Configuration (GC)
db2 CONNECT TO gc USER db2admin USING %db2password%
REM ------------------------------
REM -- Do a runstats so DB2 knows how to work efficiently
db2 -x "select 'runstats on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),' and indexes all;'from syscat.tables where type = 'T' " > runstats.out
db2 -tvf runstats.out
REM ------------------------------
REM -- Do a reorgchk so DB2 knows how to reorganise the tables
db2 -x "select 'reorgchk update statistics on table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';' from syscat.tables where type = 'T' " > reorgchk.out
db2 -tvf reorgchk.out
REM ------------------------------
REM -- Do a reorg on all tables but exclude DEADLOCK tables
db2 -x "select 'reorg table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorg.out
db2 -tvf reorg.out
REM ------------------------------
REM -- Do a reorg on all tables indexes but exclude DEADLOCK tables
db2 -x "select 'reorg indexes all for table',substr(rtrim(tabschema)||'.'||rtrim(tabname),1,80),';'from syscat.tables where type = 'T' and not tabname like '%DEADLOCK%'" > reorgindexes.out
db2 -tvf reorgindexes.out
REM ------------------------------
REM -- Do a final reorgchk to make sure that stats are now accurate given all the data movement around on pages
REM -- Do a final reorgchk
db2 reorgchk update statistics on table all