Sunday, September 27, 2009

Online REORG

In simple terms, when you use SHRLEVEL CHANGE in the REORG utility, it is called 'Online REORG'.


First, let's see what was prior to online REORG:
  1. UNLOAD the data
  2. Redifine the tablespace
  3. RELOAD the data
  4. REBUILD the indexes

During UNLOAD, other users can read the tablespace. They can not update the tablespace. During other steps neither read nor updates are allowed. Typically, it's long an outage to the tablespace.




Online REORG:


Online reorg works by reloading the reorged tablespace and rebuilding the indexes into different datasets (shadow tablespaces and indexes). It then switches the original datasets and the new ones at the end of the reorg - the idea is that the objects are only unavailable for this short time at the end, not during the reload and rebuild phases which can be protracted for large objects. Online reorg comes in two flavours - one which allows applications to read and update during the reorg, and one which allows only reading.

It is determined by the keyword SHRLEVEL. SHRLEVEL has 3 options:

  • SHRLEVEL NONE - Traditional
  • REORGSHRLEVEL CHANGE - 'Online' REORG - Allows reads & Writes
  • SHRLEVEL REFERENCE - 'Online' REORG - Allows only reads

Be careful when choosing SHRLEVEL REFERENCE as it's an outage on the tablespace.

1 comment:

  1. How does the shadow dataset get defined and removed if you are using DB2 stogroups and SMS managed storage? Thanks.

    ReplyDelete