Professional Documents
Culture Documents
Applies to:
All SAP releases on DB2 for Linux, UNIX and Windows Version 9.7. For more information, visit the
Landscape Design and Architecture homepage.
Summary
Reclaiming unused storage below the table spaces' high-water mark was a lengthy and sometimes a
troublesome task. This involved using a combination of various DB2 tools, which at times, was not fully
guaranteed to reduce the high-water mark. Now with DB2 9.7 and table spaces enabled with reclaimable
storage, it is possible to easily lower the high-water mark and reclaim the trapped free space. This paper
provides an overview of the extent movement process, as well as examples on how to start and monitor the
process.
Author Bio
Since joining SAP in 2005, Edgar Maniago, a Software Engineer, has been a member of the
IBM SAP Integration and Support Centre located in the Toronto IBM Lab. He currently tests,
develops and integrates new features of DB2 with SAP. Through his SAP development
support role and being a Customer Advocate for IBM, Edgar assists SAP consultants and
customers with activities such as troubleshooting and performance optimization.
Table of Contents
The High-Water Mark Problem ........................................................................................................................... 3
Reducing the High-Water Mark Pre DB2 9.7...................................................................................................... 4
Reducing the High-Water Mark in DB2 9.7 ........................................................................................................ 4
Extent Movement Overview ............................................................................................................................ 4
Table Space Prerequisites .............................................................................................................................. 5
Reducing the HWM in Automatic Storage Table Spaces ............................................................................... 5
Reducing the HWM in DMS Table Spaces ..................................................................................................... 5
Monitoring the Extent Movement .................................................................................................................... 6
Example: Reducing the HWM with DB2 9.7 ....................................................................................................... 8
Check Table Space for Free Space ................................................................................................................ 8
Determine the Free Pages below the High-Water Mark ................................................................................. 8
Start the Extent Movement and Reclaim Space ............................................................................................. 8
Monitor the Extent Movement ......................................................................................................................... 9
Check the Results ......................................................................................................................................... 10
Related Content ................................................................................................................................................ 11
Copyright........................................................................................................................................................... 12
Once the above command has been executed, the extent movement operation will run asynchronously. To
monitor the progress, see the section Monitoring the Extent Movement below.
If the MAX option is specified, the database manager will try to reduce the high-water mark as much as
possible, followed by a reduction in the container size. With the SIZE option, the database manager will try
to reduce the table space by the specified amount.
The extent movement operation can be stopped by re-running the ALTER..REDUCE STOP command. All
extents that have been moved will be committed, the high-water mark will be reduced to its value at the time
of the abort and containers will be reduced.
After running the above command, the extent movement operation will run asynchronously. To monitor the
progress, see the section Monitoring the Extent Movement below.
Once the high-water mark has been reduced the free space can now be reclaimed by calling the regular
REDUCE options of the ALTER TABLESPACE command.
TBSP_TYPE Table space type. Only DMS table spaces can have
their high-water mark lowered through extent
movement.
TBSP_PAGE_TOP The page in the table space that is holding the high-
water mark.
Not all the columns of MON_GET_TABLESPACE are shown in the above table, only the monitor elements
related to the table space pages and extents.
The table function MON_GET_EXTENT_MOVEMENT_STATUS is used to monitor the asynchronous extent
movement. The following is returned by the table function:
Column name Description
Not all the columns of MON_GET_EXTENT_MOVEMENT_STATUS are shown in the table above.
The table space snapshot is deprecated with DB2 9.7. Therefore the table spaces’ states have not been
updated to reflect the new state of MOVE_IN_PROGRESS. For example, the following is returned while the
extent movement is in progress:
db2 get snapshot for tablespaces on LRP
Tablespace name = EXTENTREMAP
Tablespace ID = 1
Tablespace Type = Database managed space
Tablespace Content Type = All permanent data. Large table space.
Tablespace Page size (bytes) = 16384
Tablespace Extent size (pages) = 2
Automatic Prefetch size enabled = Yes
Buffer pool ID currently in use = 1
Buffer pool ID next startup = 1
Using automatic storage = Yes
Auto-resize enabled = Yes
File system caching = No
Tablespace State = 0x'00080000'
Detailed explanation:
Tablespace Prefetch size (pages) = 8
As shown above, the table space state shows a ‘0x0008000’ and the detailed explanation field is blank.
Therefore, it is best to use the new table functions to monitor the extent movement.
1 record(s) selected.
We see that this automatic storage table space has 6526 free pages and that it is enabled for reclaimable
storage.
1 record(s) selected.
Looking at the column TBSP_PAGE_TOP, we see that the high-water mark is 3536394 pages. Looking at
the column TBSP_TOTAL_PAGES, we see that the total pages used by the table space is 3538280. So
there are only 1886 free pages above the high-water mark and 4640 free pages below the high-water mark.
With older versions of DB2, those 4640 pages would be trapped since the high-water mark cannot be
lowered.
Since this table space has been created with DB2 9.7 and it is enabled for reclaimable storage, the high-
water mark can be reduced through extent movement.
The above command will reduce the high-water and reclaim the maximum amount of space. After entering
the command, it will return immediately and the process will run asynchronously. The extent movement can
then be monitored through the new table functions.
1 record(s) selected.
The column NUM_EXTENTS_MOVED shows the number of extents that have already been moved, while
the column NUM_EXTENTS_LEFT shows the number of extents remaining that have to be moved. The
TOTAL_MOVE_TIME is the total elapsed time, in milliseconds, taken to move the extents.
Querying the table space status with the MON_GET_TABLESPACE table function will show that the extent
movement is currently in progress:
db2 "select varchar(tbsp_name, 15) as tbsp_name, tbsp_state from table
(mon_get_tablespace('EXTENTREMAP',-2)) as t"
TBSP_NAME TBSP_STATE
--------------- -------------------------
EXTENTREMAP MOVE_IN_PROGRESS
1 record(s) selected.
Table space snapshots can still be used to monitor the extent movement as well. However, they are
deprecated and will be removed in future releases. While the extent movement is taking place, the following
is returned:
db2 get snapshot for tablespaces on LRP
Tablespace name = EXTENTREMAP
Tablespace ID = 1
Tablespace Type = Database managed space
Tablespace Content Type = All permanent data. Large table space.
Tablespace Page size (bytes) = 16384
Tablespace Extent size (pages) = 2
Automatic Prefetch size enabled = Yes
Buffer pool ID currently in use = 1
Buffer pool ID next startup = 1
Using automatic storage = Yes
Auto-resize enabled = Yes
File system caching = No
Tablespace State = 0x'00080000'
Detailed explanation:
Tablespace Prefetch size (pages) = 8
As seen above, the table space state 0x00080000 indicates that the extent movement is in progress.
When the extent movement starts, the following is shown in db2diag.log:
2009-04-20-14.02.27.955106-240 I180293615A479 LEVEL: Warning
PID : 217256 TID : 12701 PROC : db2sysc 0
INSTANCE: db2lrp NODE : 000 DB : LRP
APPHDL : 0-29584 APPID: *LOCAL.DB2.090420180227
AUTHID : DB2LRP
EDUID : 12701 EDUNAME: db2agent (LRP) 0
FUNCTION: DB2 UDB, buffer pool services, sqlbExtentMovementEntryPoint, probe:4608
DATA #1 : <preformatted>
Extent Movement started on table space 1
...
After the extent movement has finished, the following can be seen in db2diag.log:
2009-04-20-15.12.41.240096-240 I180299899A562 LEVEL: Warning
PID : 217256 TID : 12701 PROC : db2sysc 0
INSTANCE: db2lrp NODE : 000 DB : LRP
APPHDL : 0-29584 APPID: *LOCAL.DB2.090420180227
AUTHID : DB2LRP
EDUID : 12701 EDUNAME: db2agent (LRP) 0
FUNCTION: DB2 UDB, buffer pool services, sqlbLockAndMoveExtents, probe:3960
DATA #1 : String, 126 bytes
The extent movement operation has moved all extents it could. There are no more free
extents lower in the tablespace. Exiting.
If we check the table space state, we can see that extent movement has finished:
db2 "select varchar(tbsp_name, 15) as tbsp_name, tbsp_id, tbsp_state from table
(mon_get_tablespace('EXTENTREMAP',-2)) as t"
1 record(s) selected.
1 record(s) selected.
The high-water mark has now been lowered from the page 3536394 to 2564712. Space has been reclaimed
as seen by the 0 free pages, as well as the decrease in the size of the DMS containers. That is, the total
number of pages in the table space has decreased from 3538280 pages to 2564740 pages.
Related Content
For more information, visit the Landscape Design and Architecture homepage.
Copyright
© 2009 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries,
zSeries, System i, System i5, System p, System p5, System x, System z, System z9, z/OS, AFP, Intelligent Miner, WebSphere,
Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, POWER5+, OpenPower and PowerPC are trademarks or registered trademarks of
IBM Corporation.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems
Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of
Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts
Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by
Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their
respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All
other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves
informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP
Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the
express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an
additional warranty.
These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the implied
warranties of merchantability, fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may
result from the use of these materials.
SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these
materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and
does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.
Any software coding and/or code lines/strings (“Code”) included in this documentation are only examples and are not intended to be
used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of
certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors
or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.