Back ground
As DB2 LUW DBAs, most of the times we've come across situations where in we observe that there is a lot of space is allocated to the tablespace above high watermark and it is not being used by the tablespace. I feel we can say that this space as wasted space per tablespace.
For optimal utilization of storage, we will try to release this unused space from tablespaces to filesystems. However, as per the restrictions (not applicable for tablespaces created in V9.7 or above) in DB2 we can release only unused space above highwater mark of the tablespaces.
Hence for releasing unused space (above highwatermark) of tablespaces in versions lesser than V9.7, consider using below commands. The commands are different for partitioned and non partitioned databases.
Resizing tablespaces in Data partitioning feature (Non DPF or single partitioned) not enabled databases
Execute below command to analyze tablespaces and get the output redirected to a file "resize.sql"
Execute the generated resize commands in "resize.sql" file to free up the space from tablespaces and give it back to underlying filesystems.
Resizing tablespaces for Data partitioning feature (DPF) enabled databases
Execute below command to analyze tablespaces and get the output redirected to a file "resize.sql"
db2 -x "with temptbsp_util as
(select MAX(TBSP_PAGE_TOP) TBSP_PAGE_TOP, MAX(TBSP_EXTENT_SIZE) EXTNT_SZ_MAX,MAX(TBSP_NUM_CONTAINERS) NUM_CONTS_MAX, SUBSTR(TBSP_NAME,1,30) TBSP_NAME from SYSIBMADM.TBSP_UTILIZATION where TBSP_AUTO_RESIZE_ENABLED=1 and TBSP_TYPE <> 'SMS' and TBSP_NAME NOT LIKE 'SYS%' and (TBSP_TOTAL_PAGES - TBSP_PAGE_TOP) > 1000 and TBSP_USING_AUTO_STORAGE=0 group by TBSP_NAME)
select TBSP_PAGE_TOP, EXTNT_SZ_MAX,NUM_CONTS_MAX,TBSP_NAME,(TBSP_PAGE_TOP + (EXTNT_SZ_MAX * 2 * NUM_CONTS_MAX))/(NUM_CONTS_MAX) TOP_PLUS_EXT10_DIV_NOOFCONTS from TEMPTBSP_UTIL with ur" | awk '{print "alter tablespace " $4 " resize (all " $5 ");"}' | tee -a resize.sql
Execute the generated resize commands in "resize.sql" file to free up the space from tablespaces and give it back to underlying filesystems.
In my next post, I would be blogging on how free up unused space under high watermark of the tablespaces in your databases.
Stay tuned till then!
No comments:
Post a Comment