summer, 2013,university training program db2 for z/os utilities - reorg

14
Summer, 2013,University Training Summer, 2013,University Training Program Program DB2 for z/OS Utilities - REORG

Upload: steve-juba

Post on 14-Dec-2015

235 views

Category:

Documents


2 download

TRANSCRIPT

Summer, 2013,University Training ProgramSummer, 2013,University Training Program

DB2 for z/OS Utilities - REORG

REORG

• REORG TABLESPACE– Recluster the data– Reclaim fragmented space– Restore free space– Bring online scheme change into effect

• REORG INDEX– Restore physical ordering of leaf pages– Reclaim fragmented space– Restore free space

Reclaim fragment space

• After creating table space

• After excessive INSERTs/DELETEs

• After REORG TABLESPACE (FREEPAGE 5)

Used page

Empty page

How clustering affects performance

• An index scan on an index with a poor cluster ratio could result in more synchronize I/Os and more Getpages

REORG TABLESPACE

TABLESPACE UNLOAD

RELOAD

SORT BUILD INDEXSPACE

TABLESPACE

SWITCH

LOG

UTILINIT UTILTERM

REORG option

option Explanation

SORTDATA If yes, the data is to be unloaded by a table space scan, and sorted in clustering order.

SCOPE All objects or only table spaces or parts in REORG-pending status

PART Indicate the set of parts to be reorged

PARALLEL To be processed in parallel or not

REORG option

SHRLEVEL option Explanation

NONE Applications can read but cannot write to the area during unloading; Applications have no access during reloading; Read-write access is allowed after reloading.

REFERENCE Applications can read but cannot write to the area during unloading; Applications can read but cannot write during reloading into the shadow copy; Read-write access is allowed after switching.

CHANGE Applications can read but cannot write to the area during unloading; Applications have read-write access to the original copy of the data during reloading; Applications can read and usually write to the original copy while applying the log of the original copy to the shadow copy; Read-write access is allowed after switching.

REORG TABLESPACE examples

• REORG TABLESPACE DBTEST01.TSTEST01• REORG TABLESPACE DBTEST01.TSTEST01

SHRLEVEL CHANGE• REORG TABLESPACE DBTEST01.TSTEST02

PART 1• REORG TABLESPACE DBTEST01.TSTEST02

PART 3:6

REORG TABLESPACE option

• DISCARD – Discard rows

• Written to SYSDISC data set or• Data set specified with DISCARDDDN keyword or• Not written (for example, lost)

– Example• REORG TABLESPACE DBTEST01.TSTEST03 DISCARD FROM TABLE USR01.EMP WHERE (WORKDEPT = ‘A’)

When to reorganizing table spaces

• REORG TABLESPACE options– INDREFLIMIT (overflow records)– OFFPOSLIMIT (non-clustered records)

• Based on real-time statistics information– REORGINSERTS/TOTALROWS > 25%– REORGDELETES/TOTALROWS > 25%– EXTENTS > 254– REORGMASSDELETE > 0– Etc

REORG INDEX

INDEXSPACE UNLOAD

BUILDINDEXSPACE

SWITCH

LOG

UTILINIT UTILTERM

REORG INDEX examples

• REORG INDEX USR01.INDEX01

• REORG INDEX USR01.INDEX01

PART 3

REUSE

When to reorganizing indexes

• Based on real-time statistics information– REORGINSERTS/TOTALROWS > 25%– REORGDELETES/TOTALROWS > 25%– EXTENTS > 254– Etc

• REORG INDEX option– LEAFDISTLIMIT (100 times the average number

of leaf pages between successive active leaf pages of the index)

When to reorganizing indexes

• Based on real-time statistics information– LEFANEAR– LEARFAR