DB2 Table maintenance automated

I have done several previous posts on this subject but I would like to bring them together here, and show you the process that I run to maintain my tables when I want too, not when DB2 decides is best. So I use my four processes that I have built so far from the articles Automated DB2 Table Reorganisation, Automated DB2 Index Reorganisation, Automated DB2 Runstats and Automated DB2 Stored procedure Rebinding and write a wrapper stored procedure to encapsulate them all.

The wrapper stored procedure is fairly simple:


This is the stored procedure that runs and keeps in line the GLOBAL schema that we have, obviously you can change GLOBAL to anything that you like. The stored procedure can then be used to automate anyway you like, the only gotcha is that the user that runs the script has to have the authority to carry out the commands. This means you can run it from a query window in the likes of Control Centre or IBM Data Studio, a bash script or a file that is run by the db2 command.

As for the schedule that we employ this is still under some testing, but due to the fact that you can never tell how long a offline table reorganisation will take and that once it has started there is no way to pause or stop it, unlike the online table reorganisations I have the 4 R’s (Reorg Table, Reorg Index, Runstats and Rebind) process running on each schema every other week. The tables that are identified for processing should only be the ones that have been identified by the inbuilt assessment stored procedures SYSPROC.REORGCHK_TB_STATS and SYSPROC.REORGCHK_IX_STATS or the tables that have been identified in table in the runstats part of the process, this should shorted the time taken to process, but I have found in testing the timings the reorganisations are greatly affected by the other processes that are going on in the instance / box at the time.

Leave a Reply

Post Navigation