Best Practice: Using DB2 Compression Feature in SAP Environment

Applies to:
All SAP releases on DB2 for Linux, UNIX and Windows Version 9 and above. For more information, visit the Landscape Design and Architecture homepage

Summary
Disk storage can often be the most expensive components of a database solution. IBM DB2 compression features will help reduce space requirement dramatically, resulting in lower storage cost and improved I/O performance. This article explains different compression featured delivered in DB2 LUW 9.1, 9.5 and 9.7, and provides general guidelines how to use these features efficently in SAP environment. Author: Lili Zhang

Company: IBM Created on: July 2010

Author Bio
Lili Zhang is a member of the IBM SAP Integration and Support Centre at the IBM Toronto Lab. Her current activities include testing of SAP applications with DB2 LUW and helping customers with problem analysis and troubleshooting. She is also a customer advocate, providing support for large customer accounts running SAP and DB2.

SAP COMMUNITY NETWORK © 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 1

Best Practice: Using DB2 Compression Feature in SAP Environment

Table of Contents
1.1 Row compression ................................................................................................................................ 3 Enabling Row compression ....................................................................................................................... 3 Performance Impact and Resource Requirement ....................................................................................... 6 1.2 Index compression............................................................................................................................... 6 Enabling Index Compression ..................................................................................................................... 7 2. Choosing Candidates for Compression...................................................................................................... 8 2.1 DB2 tools to estimate the compression ratio......................................................................................... 8
2.1.1 DB2 INSPECT utility ........................................................................................................................................... 8 2.1.2 ADMINTABCOMPRESSINFO view and ADMIN_GET_TAB_COMPRESS_INFO table function ....................... 9 2.1.3 ADMINTABCOMPRESSINFO view and ADMIN_GET_TAB_COMPRESS_INFO_V97 table function ............. 10 2.1.4 ADMIN_GET_INDEX_COMPRESS_INFO table function (available in DB2 9.7) .............................................. 11

2.2 SAP tools to estimate the space savings ............................................................................................ 12
2.2.1 DBAcockpit ....................................................................................................................................................... 12 2.2.2 SAP compression tool: /ISIS/ZCOMP ............................................................................................................... 13

2.3 Calculating the number of tables to be compressed to achieve desired storage savings ..................... 15 2.4 Tables that shouldn‟t be compressed .............................................................................................. 16 3. Preparing for compression ...................................................................................................................... 17 3.1 Enabling the tables for large RIDs (Optional) ...................................................................................... 17 3.2 REORG consideration ....................................................................................................................... 18
3.2.1 Reorg using temporary tablespace ................................................................................................................... 18 3.2.2 Reorg within same DMS tablespace ................................................................................................................. 19

3.3 Managing tablespace fragmentation................................................................................................... 20 4. Enabling compression with SAP tools ...................................................................................................... 22 4.1 Installation tools ................................................................................................................................. 22 4.2 Enabling compression for existing system .......................................................................................... 22
4.2.1 DBAcockpit ....................................................................................................................................................... 22 4.2.2 /ISIS/ZCOMP tool.............................................................................................................................................. 25 4.2.3 DB6CONV......................................................................................................................................................... 27 4.2.4 Compression support in BW system ................................................................................................................. 28 4.2.3 Compressing AS Java tables ............................................................................................................................ 29

4.3

Migration tools ................................................................................................................................ 29
R3load.......................................................................................................................................................... 29 Sample export via /ISIS/ZCOMP Tool .......................................................................................................... 30

4.3.1 4.3.2

5. Post Compression Consideration ............................................................................................................ 33 5.1 Monitoring the compression quality .................................................................................................... 33
5.1.1 Evaluating compression quality......................................................................................................................... 33 5.1.2 Rebuilding Compression Dictionary .................................................................................................................. 33

5.2 Reclaiming space .............................................................................................................................. 34 5.3 Backup Performance ......................................................................................................................... 35 6. Reference numbers from SAP system ..................................................................................................... 35 Related Content .......................................................................................................................................... 36 Disclaimer and Liability Notice ..................................................................................................................... 37

SAP COMMUNITY NETWORK © 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2

Best Practice: Using DB2 Compression Feature in SAP Environment

1. Introduction
Storage cost is one of the major considerations in today‟s database solution. Since V8, DB2 has delivered several compression features to help customers better manage their storage growth. One of the most effective compression solutions is row compression which was introduced in DB2 9.1. It significantly reduces the space requirement by eliminating repetitive data in the tables. In DB2 9.7, index compression was introduced to futher cut down the space comsumption for index objects. For a typical SAP ERP system, customers have experienced space savings of more than 50%, along with better application response time. DB2‟s compression features are tightly integrated into SAP software. Customers can easily get compression estimate and enable compression through different SAP tools.This paper explains different compression features delivered in DB2 LUW 9.1, 9.5 and 9.7, and how to make best use them in an SAP environment. 1.1 Row compression Row compression is also refered to as “deep compression”. It uses a dictionary based LZ (Lempel-Z) algorithm to compress data records. When row compression is activated, DB2 first scans the table for repetitive patterns. These patterns could span across multiple columns, or reside within a substring of a column. After analyzing the data, it creates a compression dictionary that maps repeated byte patterns to much smaller symbols. These symbols then replace the longer byte patterns in the table rows. The following diagram demonstrates how it works:

The degree of compression depends on the data itself, and the quality of the data dictionary. The compression dictionary is physically stored along with the table data and loaded into database heap when the table is accessed. It is static and remains in the table even when all the data is deleted. The maximum size of dictionary is 150K whereas in a typical SAP system, the average size of the dictionary is 75K. In a multi-partitioned environment, a dictionary is created for each data partition. With DB2‟s row compression feature in 9.1 and 9.5, only data stored in base table rows can be compressed. Indexes, LONGs and LOBs are not eligible for compression. With DB2 9.7, you can use the LOB inlining feature to include small LOBs in the base table row so that they can be compressed with row compression. In addition DB2 writes log records in compressed format as well. Enabling Row compression In order to use row compression for the table, the following two prerequists must be satisfied: 1. The compress attribute for the table is set to YES By default, the compression flag is set to OFF, and it can be enabled with the CREATE TABLE or ALTER TABLE command using the COMPRESS clause.

SAP COMMUNITY NETWORK © 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 3

com | BOC . If a compression dictionary already exists on the table. The compression dictionary is built. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . compress yes % db2 alter table MARA … compress yes 2.  Offline reorg. On the other hand. If the COMPRESS attribute has been turned off.sap. The classic way to build a compression dictionary is through an offline reorg operation. KEEPDICTIONARY option will create the compression dictionary if the size of the table is big enough( about 1-2MB) and there is enough data in the data.sdn. the RESETDICTIONARY option will uncompress the data and also remove the existing dictionary from the table. Any data updated or inserted into the table after dictionary creation will be compressed.Best Practice: Using DB2 Compression Feature in SAP Environment Example: % db2 create table MARA…. A new clause ROWCOMPESTIMATE was added to the INSPECT utility to provide a compression estimate function for the table.com 4 .boc. Alternatively you can use the INSPECT utility with the ROWCOMPESTIMATE clause to create the compression dictionary. KEEPDICTIONARY is the default setting. When this utility is called. the dictionary is saved and stored with the table. the KEEPDICTIONARY option will reorgnize the table based on the existing dictionary and the RESETDICTIONARY will replace the existing dictionary with a new one and then compresses the table.bpx. If the COMPRESS attribute for the table is set to YES. and the table doesn‟t have a dictionary.com | BPX .  DB2 INSPECT utility.sap. the RESETDICTIONARY option will create dictionary and compress the table as long as there is at least 1 row in the table. it exams the exisiting data and creates a compression dictionary which is used to estimate the compression ratio. If the table is enabled for compression and does not have a dictionary. In DB2 9. the REORG TABLE command has been enhanced with two options related to compression: KEEPDICTIONARY and RESETDICTIONARY.sap. It first constructs a compression dictionary and then compresses the data in the table.

SAP COMMUNITY NETWORK © 2009 SAP AG SDN .boc.sap. The existing data is not compressed unless a record gets changed. a compression dictionary is created automatically as part of data growth operation (insert. a compression dictionary is automatically created when a new page is allocated to the table after the compression flag was turned on.bpx. DB2 scans the table and builds a compression dictionary synchronously. The following diagram demonstrates how it works for a newly created table: For existing tables with size greater than the threshold. When ADC is triggered.5. The amount of data to be scanned is limited to the first portion of table (about 2M).sap. load and redistribute) when the following three conditions are satisfied: 1) The COMPRESS attribute for the table is set to YES.com | BOC .5 and above) Starting with DB2 9. After the dictionary is created. 2) No compression dictionary exists on the table.Best Practice: Using DB2 Compression Feature in SAP Environment  Automatic Dictionary Creation ADC (Available in DB2 9. 3) The table size grows beyond the threshold (about 2M). subsequent data populated into the table is subject to be compressed.com | BPX .com 5 .sap. There may be a slight performance impact when the threshold is reached and the dictionary is being created. so that there is sufficient data to construct a compression dictionary.sdn. import.

However. Note: Index compression is not supported for MDC block indexes. if the system is already CPU bound. You can find detailed description on different algorithms used for index compression in the white paper Index Compression on SDN. Performance Impact and Resource Requirement In addition to the space savings. as more data can be cached in the bufferpool. SAP recommends setting database parameter DBHEAP to automatic. SAP systems have shown an increase of 0%-10% in CPU usage on a compressed system. as ADC constructs the dictionary from a subset of data. this memory will be released. Queries against compressed data can be performed with fewer I/O operations.sdn. --UTIL_HEAP_SZ During dictionary creation. For index compression. because each read from disk brings in more data. The bufferpool hit ratio can also increase. compression can also improve system performance. the extra CPU cycles used or compression can be offset by the efficiency gained through fewer I/O operations. However. it may be necessary to increase CPU capacity in order to maintain desirable performance results. and customers may notice a slight increase in the DBHEAP memory usage for systems with compressed tables.com | BOC . DB2 requires up to 10 MB memory from the utility heap in order to hold the data records that are sampled by the algorithm. However. When index compression is enabled. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . Once the dictionary is built. especially in I/O bound systems. In most cases. there is a tradeoff in the form of CPU cycles and memory requirement to compress and decompress the data. SAP customer systems have shown 0-5% increase in CPU cycles required for compressing and decompressing the indexes. DB2 chooses one of the following algorithms to compress the index pages:    Variable slot directory RID list compression Prefix compression. 75KB is needed for each compression dictionary in a SAP system. and it remains there until the database is deactivated. its dictionary is loaded in the database heap. our tests showed up to 50% reduction in the overall index size.  CPU overhead On average. On average.2 Index compression With DB2 9.com 6 . index compression also increases disk I/O throughput and bufferpool quality. Depending on the number of index compressed and the type of workload.boc.  1.sap.com | BPX . index objects can also be compressed to further reduce the storage requirement for index pages.7.sap. In addition to space savings. the quality of the dictionary may not be optimal for large tables.Best Practice: Using DB2 Compression Feature in SAP Environment Note: ADC reduces the need to create a dictionary manually. Memory consumption --DBHEAP When a compressed table is first accessed.bpx.sap.

you can use the COMPRESS clause on the CREATE INDEX statement to explicitly create the index in compressed format. The data in the table does not have to be compressed. the REORG has to be run offline.boc. If the table is not enabled for compression.sap. In this case. Example: % db2 alter index MARA~0 … compress yes % db2 reorg indexes all for table MARA Note: W hen you enable row compression with the ALTER TABLE command. you can use the ALTER INDEX command to set the COMPRESS attribute to YES. Compression enabled table refers to any table with COMPRESS attribute set to YES.7 FP1 contains important performance enhancement for index compression.bpx.com 7 . and perform online or offline REORG on the indexes for index compression.Best Practice: Using DB2 Compression Feature in SAP Environment Enabling Index Compression Note: DB2 9. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .com | BOC .7 FP1 or higher for index compression implementation.sap.  Activating compression on new indexes If an index is created on a compression enabled table. it will be compressed by default.sdn. You need to set the COMPRESS attribute for each index separately.compress yes  Activating compression on existing indexes For existing indexes.sap. The REORG TABLE command can be used to compress data and indexes at the same time. the COMPRESS attribute for the indexes defined on the table does not get changed. Please apply DB2 9. Example: % db2 create index MARA~6 …. No additional steps are needed.com | BPX .

The compression result is saved in a binary output file in the db2dump directory.29.com | BOC . This tool takes a sample of the table data.1 only) Compression dictionary size Expansion dictionary size If a table‟s COMPRESS attribute is set to YES.sap. the INSPECT utility can be used to get compression estimate with the ROWCOMPESTIMATE clause. builds a dictionary from it.sap.com | BPX . and estimates how much space can be potentially saved based on the dictionary.813034 Action: ROWCOMPESTIMATE TABLE Schema name: SAPLRP Table name: COSP Tablespace ID: 10 Object ID: 1892 Result file name: cosp_estimate Table phase start (ID Signed: 1892.1.sdn. You will get the following information in the INSPECT report:      Percentage of bytes saved from compression Percentage of pages saved from compression Percentage rows ineligible for compression due to small data size(applicable in DB2 9. the dictionary created by the INSPECT utility will be saved and stored together with the table object.sap. The DB2INSPF utility can then be used to convert the output into readable format. For index compression estimate. Tablespace ID: 10) : SALRP. 2.1 DB2 tools to estimate the compression ratio 2.52. use ADMIN_GET_INDEX_COMPRESS_INFO table function as described in 2. and no dictionary exists on the table. we will explain different tools available from DB2 and SAP that provide estimates on the space savings with compression.COSP Data phase start. In this section. Choosing Candidates for Compression Before enabling compression. Example: db2lrp> db2 inspect rowcompestimate table name cosp schema saplrp results keep cosp_estimate DB20000I The INSPECT command completed successfully. Object: 1892 Tablespace: 10 Row compression estimate results: Percentage of pages saved from compression: 87 Percentage of bytes saved from compression: 87 Compression dictionary size: 37760 bytes.boc. This provides an alternative to the offline reorg procedure to build the compression dictionary. db2lrp> cd /db2/LRP/db2dump db2lrp> db2inspf cosp_estimate cosp_estimate. Note: The INSPECT utility only provides estimate for row compression. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .1.4. Data phase end.out db2lrp> cat cosp_estimate. Expansion dictionary size: 32768 bytes.Best Practice: Using DB2 Compression Feature in SAP Environment 2.bpx.com 8 .1 DB2 INSPECT utility With DB2 9. you should get a compression estimate to decide if the table is a suitable candidate for compression. Unsigned: 1892.out DATABASE: LRP VERSION : SQL09071 2009-12-16-16. Table phase end.

Syntax >>-ADMIN_GET_TAB_COMPRESS_INFO--(--tabschema--.boc.sap.000000 37760 32768 18799934 87 87 144 The ADMIN_GET_TAB_COMPRESS_INFO table function allows you to specify a schema.5.admintabcompressinfo where compress_attr='Y'" TABSCHEMA TABNAME DBPARTITIONNUM DATA_PARTITION_ID COMPRESS_ATTR DICT_BUILDER DICT_BUILD_TIMESTAMP COMPRESS_DICT_SIZE EXPAND_DICT_SIZE ROWS_SAMPLED PAGES_SAVED_PERCENT BYTES_SAVED_PERCENT AVG_COMPRESS_REC_LENGTH _____________________________________________________________________________________ SAPLRP COSP 0 0 Y REORG 2009-12-17-17. table name and an execution mode to get the compression information for a specific table. You can use a predicate in the query to get the information you are interested in. Example: db2lrp> db2 "select * from sysibmadm.2 ADMINTABCOMPRESSINFO view and ADMIN_GET_TAB_COMPRESS_INFO table function In DB2 9.1.7 SAP COMMUNITY NETWORK © 2009 SAP AG SDN .sdn.com 9 .PAGES_SAVED_PERCENT BYTES_SAVED_PERCENT.com | BOC .'ESTIMATE')) as t" COMPRESS_ATTR ROWS_SAMPLED PAGES_SAVED_PERCENT BYTES_SAVED_PERCENT AVG_COMPRESS_REC_LENGTH -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------N 10331351 82 82 86 1 record(s) selected. Note: The ADMIN_GET_TAB_COMPRESS_INFO table function has been deprecated and replaced by the ADMIN_GET_TAB_ COMPRESS_INFO_V97 table function in DB2 9. AVG_COMPRESS_REC_LENGTH * from table(admin_get_tab_compress_info('SAPLRP'.30.14.sap.bpx. The ADMINTABCOMPRESSINFO view and the ADMIN_GET_TAB_COMPRESS_INFO table function return the following information on table compression:  TABSCHEMA  TABNAME  DBPARTITIONNUM  DATA_PARTITION_ID  COMPRESS_ATTR  DICT_BUILDER  DICT_BUILD_TIMESTAMP  COMPRESS_DICT_SIZE  EXPAND_DICT_SIZE  ROW_SAMPLED  PAGES_SAVED_PERCENT  BYTE_SAVED_PERCENT  AVG_COMPRESS_REC_LENGTH Example: db2lrp> db2 "select COMPRESS_ATTR.com | BPX . a new administrative view ADMINTABCOMPRESSINFO and a table function ADMIN_GET_TAB_COMPRESS_INFO can be used to get compression information on the tables.'BKPF'.--tabname--.sap. The ADMINTABCOMPRESSINFO administrative view returns a report of compression information for all the tables in a database. ROWS_SAMPLED.--execmode--)->< The execution mode can be REPORT or ESTIMATE.Best Practice: Using DB2 Compression Feature in SAP Environment 2. The REPORT mode displays compression information as of last generation of the data dictionary and the ESTIMATE mode provides estimate based on the current data.

7.sap. The REPORT mode will display compression information as of last generation of the data dictionary.com | BOC . AVG_COMPRESS_REC_LENGTH from sysibmadm.com | BPX .Best Practice: Using DB2 Compression Feature in SAP Environment 2. you can use the ADMINTABCOMPRESSINFO administrative view and the ADMIN_GET_TAB_COMPRESS_INFO_V97 table function to get compression estimate for the tables.boc. Here is a list of compression information that can be retuned:  TABNAME  DBPARTITIONNUM  DATA_PARTITION_ID  COMPRESS_ATTR  DICT_BUILDER  DICT_BUILD_TIMESTAMP  COMPRESS_DICT_SIZE  EXPAND_DICT_SIZE  ROW_SAMPLED  PAGES_SAVED_PERCENT  BYTE_SAVED_PERCENT  AVG_COMPRESS_REC_LENGTH  OBJECT_TYPE Example: db2lrp> db2 "select TABNAME. PAGES_SAVED_PERCENT.--tabname--.'ESTIMATE')) as t" COMPRESS_ATTR ROWS_SAMPLED PAGES_SAVED_PERCENT AVG_COMPRESS_REC_LENGTH OBJECT_TYPE --------------------------------------------------------------------------------------------------------------------------------------------------------------------- N N 2 record(s) selected.bpx.3 ADMINTABCOMPRESSINFO view and ADMIN_GET_TAB_COMPRESS_INFO_V97 table function In DB2 9. The syntax for ADMIN_GET_TAB_COMPRESS_INFO_V97 table function is the same as ADMIN_GET_TAB_COMPRESS_INFO.sap.sdn.admintabcompressinfo where compress_attr='Y‟” TABNAME PAGES_SAVED_PERCENT AVG_COMPRESS_REC_LENGTH OBJECT_TYPE -----------------------------------------------------------------------------------------------------------------------------------COSP 87 144 DATA COSP 0 0 XML 2 record(s) selected. The new administrative view and table function adds an additional element OBJECT_TYPE in the result set to support XML compression estimate.sap. and this function can be used to retrieve compression estimate for a single table. ROWS_SAMPLED . The ESTIMATE mode will estimate space savings based on current data. Example: db2lrp> db2 "select COMPRESS_ATTR.com 10 .1.PAGES_SAVED_PERCENT AVG_COMPRESS_REC_LENGTH OBJECT_TYPE * from table(admin_get_tab_compress_info_v97('SAPLRP'.--execmode--) The execution mode can be REPORT or ESTIMATE. 10331351 0 82 0 86 0 DATA XML SAP COMMUNITY NETWORK © 2009 SAP AG SDN . The OBJECT_TYPE can be „DATA‟ or „XML‟. Syntax ADMIN_GET_TAB_COMPRESS_INFO_V97--(--tabschema--.'BKPF'.

7) This new table function returns estimated space savings for uncompressed indexes.'COSP'.--objectschema--.-- dbpartitionnum--. pct_pages_saved from table(admin_get_index_compress_info('T'.bpx.'SAPLRP'. index_compressed. Syntax ADMIN_GET_INDEX_COMPRESS_INFO--(--objecttype--.sap.compress_attr.index_compressed.Best Practice: Using DB2 Compression Feature in SAP Environment 2.'SAPLRP'. index COSP~0 is physically compressed. If the index is physically compressed (INDEX_COMPRESSED is "Y").sdn. Datapartitionid is the database partition ID.com | BOC .0)) as t" INDNAME COMPRESS_ATTR INDEX_COMPRESSED PCT_PAGES_SAVED ----------------------------------------------------------------------------------------------------------------COSP~0 Y Y 30 COSP~1 N N 16 COSP~2 N N 66 SAP COMMUNITY NETWORK © 2009 SAP AG SDN . compress_attr.cosp with distribution and sampled detailed indexes all DB20000I The RUNSTATS command completed successfully. The PCT_PAGES_SAVED value for COSP~1 and COSP~2 represents the estimated percentage of leaf pages saved. altena:db2lrp> db2 "select indname. use the value -2 or null. use the value -2. To specify that the data is requested for all partitions. and COSP~1 and COSP~2 are not compressed.0. Objectschema is the name of the schema where the object belongs Objectname is the name of the object Dbpartitionnum is the database partition number.--objectname--.sap. then this value reports the PCTPAGESSAVED value from the system catalog view.4 ADMIN_GET_INDEX_COMPRESS_INFO table function (available in DB2 9. The value of 0 for index cosp~0 means no statistics has been collected for this index after compression.'COSP'. Example: altena:db2lrp> db2 runstats on table saplrp.--datapartitionid--) Where:      Objecttype is „T‟ for table and „I‟ for index.0)) as t" INDNAME COMPRESS_ATTR INDEX_COMPRESSED PCT_PAGES_SAVED ----------------------------------------------------------------------------------------------------------COSP~0 Y Y 0 COSP~1 N N 16 COSP~2 N N 66 In the above example. The ADMIN_GET_INDEX_COMPRESS_INFO table function returns the following information about index:  INDSCHEMA  INDNAME  TABSCHEMA  TABNAME  DBPARTITIONNUM  IID  DATAPARTITIONID  COMPRESS_ATTR  INDEX_COMPRESSED  PCT_PAGES_SAVED  NUM_LEAF_PAGES_SAVED Example: db2lrp> db2 "select indname.com | BPX . To specify that the data is requested for all partition. If the index is already compressed.com 11 . it showed that actual space savings for index cosp~0 is 30%. After we updated the statistics.0.sap.pct_pages_saved from table(admin_get_index_compress_info('T'.boc. it reports the index compression statistics from the catalogs.1.

sap.sap.com 12 . You can get compression information as well as activate compression for a specific table through DBAcockpit->Space-> Single Table Analysis. To run a compression check for a table. and choose your execute option in the dialog box. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . 2.bpx.Best Practice: Using DB2 Compression Feature in SAP Environment 2.com | BOC .0 Support Package 12 or SAP Basis Release 7. In DBAcockpit.com | BPX .2. click on Space -> Single Table Analysis. execute the following steps: 1.boc. Click on the Compression Check button at the top of the page.2 SAP tools to estimate the space savings 2.10. row compression support has been integrated into the DBAcockpit.sdn. and enter the table name to be analyzed.sap.1 DBAcockpit As of SAP Basis Release 7.

sdn. 2.sap. If it is the first time you access this tool.com 13 . After the job has finished.com | BPX .Best Practice: Using DB2 Compression Feature in SAP Environment 3. customers can easily get a list of candidate tables that will provide the most space savings when compressed. This tool can be downloaded from SAP via note 980067 and installed on any SAP system from 4. It exams the largest N (as defined by the user) tables in database that are not compressed and not volatile. no data is shown on the screen.sap. the job may run from several minutes to a couple of hours.boc.2. With /ISIS/ZCOMP. Execute report /ISIS/ZCOMP in transaction se38. If the estimated row compression ratio is over 25%. The job to retrieve a list of suitable candidate runs in the background. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . click on the Compression Status tab to display the compression check result. 2.com | BOC . Procedure: 1.6C onwards. The result set is ordered by the table‟s physical data size. Click on the Identify Candidates for Compression button.2 SAP compression tool: /ISIS/ZCOMP /ISIS/ZCOMP is a standalone ABAP tool that provides multiple compression functionalities in a user friendly interface. the table is considered suitable for compression and added to the candidate list. Depending on the number of tables to retrieve and the amount of data in the tables.sap.bpx.

The progress of the job can be monitored through transaction sm37.sap. By default. a list of candidate tables ordered by data object size is displayed. 4.Best Practice: Using DB2 Compression Feature in SAP Environment 3.sap.bpx. and the number of tables to analyze is 25.com 14 . 5.com | BPX . Change the default entry as required. A new dialog box “Schedule Job to Identity Table Candidates” is displayed.sap. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .com | BOC .sdn.boc. The job name is ZCOMP: GET_CANDIDATES. When the job has finished. the job starts in batch mode 5 minutes after the current timestamp.

com | BPX . the benefit of compressing the table gets smaller. If your database is on DB2 9. If you want to get a new estimate on the table at a later time.3 Calculating the number of tables to be compressed to achieve desired storage savings There are thousands of tables in a typical SAP system and usually it is the largest N tables that use the majority of the space.bpx.sap.7.sap. 2. index compression is also supported.sap.7. As the table gets smaller. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .boc. Tables are compressed in sequence of their physical size (excluding LOBs).sdn. The following diagram from a customer ERP system displays the relationship between the number of tables compressed and the overall space savings.com 15 . the Total Estimated % of Pages saved and Approx MB Saved numbers include row compression and index compression savings. Compressing these large tables can reduce your database size significantly. you can highlight the tables in the list and click on the Estimate button to schedule the job.com | BOC .Best Practice: Using DB2 Compression Feature in SAP Environment Note: Starting with DB2 9.

which is very close to the 45% compression ratio we get for compressing the entire database.com | BPX . the compression ratio for such table is very low. you can calculate how much space you would save in total and the number of tables that need to be compressed to get the desired compression ratio. It is hard to maintain a satisfactory compression ratio if the table is constantly going through heavy update. 2. the compression ratio is about 40%. 3. we can see the ultimate compression ratio for the database is a little over 45%.4 Tables that shouldn’t be compressed In general. we get 30% reduction of the total storage space. Based on the values returned in approx MB Saved column. The /ISIS/ZCOMP tool is able to provide compression estimate for a list of suitable candidates ordered by their physical data size. You can achieve meaningful space savings by compressing indexes only on SAP clustered tables. SAP clustered tables. Always get compression estimate before you enable compression for the table. Note: Tables which are not suitable for row compression due to low compression ratio can still be considered for index compression. When the first 40 tables are compressed. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . tables with relatively small size do not need to be considered for compression as the benefit is negligible.com 16 .boc. 5.Best Practice: Using DB2 Compression Feature in SAP Environment The customer database size is 770G and the largest 20 tables use 360G in total.sap. After compressing these 20 tables.com | BOC . which leads to more overflows.sap. the updated row in compressed format may not fit into the current data page even though the uncompressed format has the same length. Volatile tables. 2. Eg. Tables with low compression ratio. From the above diagram. As a rule of thumb. Tables with small size or the average row length is smaller than the minimum row length of the page.bpx.sap. Tables with high frequency of update. As data is already stored in SAP compressed format in SAP clustered tables.sdn. 4. In addition. the following tables are not suitable for compression: 1.

DB2 used 4 byte RIDs (3 bytes for page number and 1 byte for slot). the use of large RID and large slot will help to achieve maximum space savings with compression. It is possible that the limit for the number of rows per page is reached before the page physically gets full. Preparing for compression 3.sap. you can get the table status from DBAcockpitSingle Table Analysis: There are two ways to enable the existing tables for large RIDs and large slot: 1. the length of each row becomes much smaller. The maximum number of rows allowed in one page for 16K pagesize tablespace is 254. Example: db2lrp> db2 "select large_rids. Convert the existing regular tablespace to large tablespace with ALTER TABLESPACE command. Limit for regular RIDs and large RIDs: Data Page Size 4K 8K 16K 32K Regular RIDs: Minimum Row Length (Byte) * 14 30 62 127 Regular RIDs: Maximum Number of Rows/Page 251 253 254 253 Large RIDs: Minimum Row Length (Byte) * 12 12 12 12 Large RIDs: Maximum Number of Rows/Page 287 580 1165 2335 *Minimum row length refers to minimum logical space for a row that is counted in the page.boc.Best Practice: Using DB2 Compression Feature in SAP Environment 3. To find out if the table is enabled for large RID and large slot.sdn.sap.----------------------Y Y Alternatively.large_slots from table(admin_get_tab_info('SAPLRP'. Prior to DB2 9. When a table gets compressed.1 Enabling the tables for large RIDs (Optional) A record Identifier (RID) is used in the database to describe which data page and where in the data page the record is located. DB2 support large RIDs (4 bytes for page number and 2 byte for slot) which greatly increases the limits are significantly increased. and execute offline REORG on the table. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . With DB2 9.com | BPX .com | BOC . It limits the size of the tables.sap.'COSP'))" LARGE_RIDS LARGE_SLOTS ------------------. and the number of records that can be stored in one page. you can use the administrative table function ADMIN_GET_TAB_INFO. For tables with estimated compressed row length smaller than the minimum row length defined in the following table.bpx. Newly created DMS tablespaces in DB2 9 use large RIDs by default.com 17 .

it is recommended not to specify an index on the reorg command when compressing tables unless reclustering is required. These two options have different impact on the tablespace layout. In addition.sap. SORT . Note: You can set the COMPRESS attribute for the table to YES before implementing one of the above options.1 Reorg using temporary tablespace If temporary tablespace is used during offline REORG.If an index was specified on the REORG TABLE command. 2.com | BPX . or a clustering index was defined on the table.The original table object is replaced by a copy from the temporary table space. a sql error will be returned.sap.A reorganized copy of the entire table is built. the shadow copy is built in the temporary tablespace. 4. RECREATE ALL INDEXES .2 REORG consideration When you choose to use offline REORG to compress the existing data. since the free pages that the table with regular RIDs can address are used by the other large RIDs enabled tables.boc. SQL1236N Table <table-name> cannot allocate a new page because the index with identifier <index-id> does not yet support large RIDs This error could occur even when the size of the table is below the old table size limit.sdn. In this way. It is recommended to enable all the tables for large RIDs in a large tablespace. This eliminates the space required for the shadow copy on the table‟s own tablespace.sap. and reorg execution time. an ABAP tool is available that can be used to activate large RIDs.2. either in its table space or in a temporary table space that was specified on the REORG TABLE command. 3. The classic table reorganization uses a shadow copy approach which consists the following four phases: 1. when a table with regular RIDS tries to allocate a new page and there is no free page available under the old tablespace limit. or a pointer is created to the newly built object within the table space of the table that is being reorganized. and use it for any SAP system starting with SAP release 4. Note: To avoid the extra time and resources it uses for sort. Otherwise. 3. the high water mark.bpx. During the replace phase.6 or higher. Move the table into a large tablespace using DB6CONV.com 18 .All indexes that were defined on the table are recreated. BUILD . Detailed instructions on how to perform this task is described in the migration guide. you have the option to use a temporary tablespace. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . or reorganize the table within the same tablespace. the rows of the table are first sorted according to that index. the shadow copy is moved back to the original table object. You can download this tool from SAP via note 1108956.Best Practice: Using DB2 Compression Feature in SAP Environment 2. The HWM of the DMS tablespace is not affected with the use of temporary tablespace. The copy process starts from the anchor of the original table and reuses only the extents occupied by the original table.com | BOC . and it is especially useful for large tables. REPLACE . the table can be compressed and enabled for large RIDs at the same time. 3.

the size of table T2 is reduced from 6 extents to 3 extents. The size of table T2 is reduced from 6 extents to 3 extents. the HWM after reorg could be different dramatically.1 to reorg the table T2 within the same tablespace. this option performs faster as the reorganized table does not need to be copied from the temporary table space. we use the same original tablespace layout as in figure 3.2. In the above example.2: Reorg T2 within the same tablespace. In the following example.Best Practice: Using DB2 Compression Feature in SAP Environment Figure 3. Depending on the amount of free space under HWM in the tablespace. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .boc. 3.2.com 19 . the shadow copy is created within the same tablespace that the table resides and a pointer is created to the newly built object afterwards.1: Reorg T2 using Temporary Tablespaces.sap.sap.bpx.com | BPX .com | BOC .2. In general. new extents are allocated and therefore the HWM gets increased. The reorganized table resides in the first 3 extents of the original table.2.2 Reorg within same DMS tablespace If the REORG command is executed without the USE clause.sdn. During the build phase.sap. DB2 will use the free space under HWM first for the shadow copy. Since there are not enough free extents under HWM to store the shadow copy. and the higher extents are freed. Figure 3.

sap.com | BOC .sdn.3: Reorg T2 within the same tablespace.2.com 20 . When such tables get compressed. In this situation. While the scattered free extents can be used for the database‟s future growth. a severely fragmented tablespace can lead to degraded backup performance.Best Practice: Using DB2 Compression Feature in SAP Environment If there is plenty of free space under HWM.3 Managing tablespace fragmentation In a tablespace where many tables reside. Figure 3. reorg within the same tablespace not only compresses the table. it is recommended to use temporary tablespace for offline REORG to avoid high impact on HWM. the shadow copy would fit into the empty space. but is also an effective way to reduce tablespace fragmentation and prepare the system to lower HWM. 3. You can execute DB2 LIST TABLE SPACE SHOW DETAILS to convert the free pending space to free. you should choose your reorg options based on the size of the table and the amount of free space in the DMS tablespace. Each time DB2 moves to a new SAP COMMUNITY NETWORK © 2009 SAP AG SDN . you may have a tablespace with small groups of used extents separated by small groups of free extents. some extents that have been occupied before become empty in the tablespace.boc. In summary. After the table is compressed with REORG command. and move the data further down in the tablespace. As a result.bpx. it's very common to have some large tables heavily interleaved with other tables. For large tables.com | BPX .sap. the prefetcher gets only a block of contiguous data at each request. the space freed is shown as free pending space in the tablespace snapshot.sap. It is because with the current design of the backup process.

starting from the smallest table. and the space freed by one table can be used by the next table reorganization. we recommend the following approach for your compression implementation on large tables: 1.bpx. this has to be done many times and can add up to the backup time considerably. non-contiguous blocks. After the large candidate tables have been compressed and moved to the target tablespace. When there are many small.sap. Alternatively. both options require a relatively long downtime to complete. Using DB6CONV eliminates the need to perform offline REORG. (Described in section 4.sdn.sap. In this way. The reorg should be run within the same tablespace that the table resides. it needs to rebuild the tablespace map to identify the next block. 3. Reorg the rest of the tables in the original tablespace. This will provide the most contiguous space. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . This step can also be replaced by moving the all the tables to other tablespaces. Use DB6CONV to move the large tables to the newly created tablespaces and compress the table at the same time. However.3. the HWM grows the least.Best Practice: Using DB2 Compression Feature in SAP Environment block of data.com 21 . To manage the tablespace fragmentation and reduce database downtime.3). The tables are accessible while being compressed. the tablespace HWM is not affected and the compressed tables are stored efficiently in the target tablespace. Create new tablespaces for data and indexes 2. you can perform a second set of reorgs inside the same tablespace. starting from the smallest table. the time required to reorganize the rest of the tables can be significantly reduced. The ultimate solution to this problem is to rebuild the tablespace by unloading and reloading all the tables from the tablespace.com | BPX . In addition.com | BOC .boc.sap.

enter the table schema and name you want to enable compression. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .2.0 Support Package 12.com 22 .4). it is not recommended to compress every table for the production system.sap. At the end of the installation. The only exception is for FACT.boc.10 or SAP Basis Release 7.bpx. the compression flag is removed for volatile tables.com | BPX . Enabling compression with SAP tools 4. 4. and it will be supported with Solman EHP 2. Under Space -> Single Table Analysis.1 Installation tools Starting from SAP NetWeaver 7. click on the Compression On/Off button at the top of the page. and one of them is “Use DB2‟s Row Compression”. ODS and PSA tables in a BW system. After the table information is displayed. To enable compression with DBACockpit.sap.com | BOC .2.1 DBAcockpit As of SAP Basis Release 7. However.sap. Note: Enabling compression during installation is a convenient way to save space for the development and QA systems.7. If the database is on DB2 9. When the option “Use DB2‟s Row Compression” is selected. you can activate row compression for a single table through DBAcockpitSpace-> Single Table Analysis. 2.Best Practice: Using DB2 Compression Feature in SAP Environment 4. SAP‟s installation tool SAPINST was enhanced with two options to minimize the database size.sdn. These tables can later be compressed through the BW interface (see section 4. you can take the following steps: 1. all the tables created during installation are compressed.0 SR 3.2 Enabling compression for existing system 4. indexes will be automatically compressed as well. Index compression is not supported for current release of DBAcockpit. as there is an associated cost to compress and uncompress the data.

sap.boc.5 or above. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .sap.bpx. ADT may be triggered as the table grows. Choose offline REORG on the next screen. If the database is on DB2 9. b: Enable compression and run reorg This option sets the COMPRESS attribute for the table to YES and performs an offline reorg to compress all the data in the table.sdn. The statistics are updated as well after the reorg operation. If Enable Compression and Run REORG is selected. 4.com | BPX .com | BOC . choose one of the following options to enable compression: a: Enable compression This option sets the COMPRESS attribute for the table to YES and does not compress the data.Best Practice: Using DB2 Compression Feature in SAP Environment 3.sap. In the dialog box for Compression Options.com 23 .

If the table size is very small and there is not sufficient data in it.sap. but no dictionary will be built. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .boc.sap. Note: SAP uses the default (KEEPDICTIONARY) with the reorg command for the Enable compression and reorg job in DBAcockpit.com | BOC .sdn.com | BPX . you can get updated information for the table by clicking on the refresh button at the top of the page.Best Practice: Using DB2 Compression Feature in SAP Environment 6.sap.com 24 . the table will be enabled for compression.bpx. When the job has finished.

To compress tables with /ISIS.bpx. you can enable compression for one or more tables from the candidates.com | BPX .2. you can take the following steps: 1.boc.ZCOMP tool.2 /ISIS/ZCOMP tool As described in section 2.sdn. After the candidates have been identified. Under the Candidates tab.2.2.Best Practice: Using DB2 Compression Feature in SAP Environment 4.com 25 . the /ISIS/ZCOMP tool can be used to list suitable candidates for compression.com | BOC .sap.sap.sap. If the database is on DB2 9.7. and click on the Compression button: 3. indexes are compressed as well. highlight the tables that you want to compress. Select you compression option and continue. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .

Newly inserted rows will be compressed. Enable table and index compression and run an offline reorg 4. Newly inserted data will be compressed (with automatic dictionary creation feature). Runstats command will be executed on the table and indexes after the reorg operation Enable compression and reorganize the table to compress all rows Enable compression and build a dictionary to compress new rows This option is only available in DB2 9. the options for compression are different.1 or 9. the compression dictionary will be created by automatic dictionary feature. If multiple tables are selected for compression.5.sap. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .sdn.Best Practice: Using DB2 Compression Feature in SAP Environment Depending on your database version. and new data inserted will be compressed This requires an offline reorg and all data in the table will be compressed.sap.com 26 . Runstats command will be executed afterwards. If database is on V9.5.sap.bpx. Runstats is executed on the table afterwards. With DB2 9.com | BOC .boc. The job is run in the background. This will activate the compression attribute for the table. You can monitor the progress of the job in transaction sm37.1. the following options are available: Enable table and index compression This will activate compression attribute for the table and all its indexes. the following options are available: Enable Compression Only This will activate the compression attribute for the table. and indexes will not be compressed.7. With DB2 9. followed by calling Inspect utility to build dictionary.com | BPX . The table and its indexes are enabled for compression and an offline reorg is performed to build a dictionary and compress all the indexes. each table is defined as a separate job in order to maximize parallel processing.

boc. 4.sap.com 27 .sap. Run report DB6CONV in se38. Select Update Statistics after Conversion to perform runstats after the move. the compressed tables are removed from candidates list and put into the compressed category.2.com | BPX . A compression dictionary is then created based on the sampled data and the full content of the source table is copied to the target table afterwards. This tool can be downloaded from SAP via note 362325. Note: Only tables compressed with /ISIS/ZCOMP tool are shown in the compressed table list.com | BOC . You can compress the table using the following steps: 1. indexes are also compressed. and the tables must be known to the ABAP dictionary. This can be done through ALTER TABLE <tabname> COMPRESS YES command or from DBAcockpitSpace->Single Table analysis.3 DB6CONV For a production system. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . you may not have a maintenance window to perform offline reorg for large tables in order to compress the data.sdn. Enable compression attribute on the table.7. This tool should be used when the activity on the table is low.Best Practice: Using DB2 Compression Feature in SAP Environment 5. With DB2 9. After the job has finished. it first creates the target table and loads a sampling of the data from the source table. The DB6CONV tool provides the capability to compress or decompress tables through online table move and no offline reorg is required. When DB6CONV is used to move a compression enabled table.sap. 2. Note: DB6CONV can only move tables of the AS ABAP schema.bpx. Enter the name of the table to be converted and the target tablespaces.

you can set the new RSADMIN parameter DB6_ROW_COMPRESSION to YES using the report SAP_RSADMIN_MAINTAIN. In addition.sap. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .0 (to be released in Q2/2010). To enable compression for PSA tables ODS tables. Please refer to OSS note 362325 to get the latest update on DB6CONV. enabling compression on BW tables not only reduces storage cost. and it reduces the maintenance effort required on the original tablespace. you will have more integrated options for table compression. Starting with DB6CONV v5. and FACT tables.com | BOC . As BW systems are usually large in size.com | BPX . and the queries are more complex and I/O intensive. two new tests are included in transaction RSRV to check the compression status for InfoProvider and PSA database tables.com 28 .2. the compressed tables are stored efficiently in the new tablespaces. but also improves query performance. In this way.Best Practice: Using DB2 Compression Feature in SAP Environment Note: It is recommended to create new tablespaces for the target table.boc.bpx.sap. 4.sap. A repair function is also provided that can be used to trigger the offline reorganization or the execution of INSPECT.4 Compression support in BW system Compression is supported in SAP BW environment.sdn.

40 and 7.sap. Please note that the user id provided for remote connection need to have to the required authority or privileges to compress the specified tables.com | BPX . With the current version of R3load Kernel 6. By default.sap. the data can be compressed directly when it is loaded into the target system.bpx. The DB6CONV tool cannot be used to compress AS Java tables.DB2 9 data row compression for SAP BW 3. please refer to SAP note 905614: SAP COMMUNITY NETWORK © 2009 SAP AG SDN . 2.00. For a single stack Java system.3. 10. Continue to insert the remaining rows into the table.sap.com 29 . 4.1 R3load The SAP R3load tool has been enhanced with several options to deploy DB2 compression features. 4.sdn.3 Compressing AS Java tables If you have a double stack system. R3load 640 To compress tables during an import with R3load. Note: With R3load 640. You can also define a different number with the environment variable DB6LOAD_COMPRESSION_THRESHOLD. it performs the following: 1. Our test showed 1% sample is fairly good enough for most of tables. The steps are the same as described in previous section and you would need to provide the right schema name for Java tables. Execute an offline reorg on the table to generate compression dictionary.Best Practice: Using DB2 Compression Feature in SAP Environment For more information on deep compression support on SAP BW systems. loadprocedure fast COMPRESS option is effective only if ROW COMPRESSION was already activated before the data was loaded for the target tables.3 Migration tools 4. please refer to the following SAP notes:  SAP Note 906765 .2. Insert/load a certain number of rows into the table uncompressed.000 rows are inserted in step 1 to build compression dictionary.x  SAP Note 926919 – DB2 9 data row compression for SAP NetWeaver BI 2004s. you can use DBAcockpit and /ISIS/ZCOMP to get compression estimate and perform compression for Java tables.boc. you can use the following commands: R3load –i …… -loadprocedure fast COMPRESS When R3load is called with the -loadprocedure fast COMPRESS option. you can setup DBAcockpit to remotely connect to the Java system to perform the task. For more information on R3load 640 compression support. 3.com | BOC .

With DB2 9. Bernoulli sampling is able to provide a representative random sample regardless of data clustering. 2.bpx.sap. If the database is at DB2 9. Detailed instructions and test results on R3load with different compression options can also be found in IBM redbook DB2 Optimization Techniques for SAP Database Migration and Unicode Conversion. Export a subset of the data on the DB2 system build in step 1 with Bernoulli sampling 3.com 30 . the compression ratio is close to what we get from reorganizing the entire table. For more information on compression support of R3load 700. SAP compression tool /ISIS/ZCOMP has a integrated DB2 Bernoulli sampling solution and provides the functionality to generate scripts needed for your system migration. Its sampling method of retrieving one row out of every n rows also gives us more representative data than using the first n% of the data. you need to add the table to the export list first. the dictionary is created by DB2 using the automatic dictionary creation feature (ADC). c.5 or higher. COMPRESS_ALL option performs best in terms of load time. With Bernoullli sampling. b.sdn.sap.  FULL_COMPRESS R3load creates all tables with COMPRESS YES attribute. The SAMPLED option is an optimal combination of load time and compression ratio. If the database is at V9.5 or higher. you need to perform the following procedure: 1. Import the sample data in the new system. each row in the table is considered independently and has the probability of P/100 to be included in the sample. To enable compression from a Bernoulli sample. Run a test migration and build the DB2 target system. and click on the “Add to Export List” button: SAP COMMUNITY NETWORK © 2009 SAP AG SDN . Our test showed with the dictionary build from Bernoulli sampling.1. Delete the sample data (the compression dictionary remains with the table) d. Import all the data into the table.com | BOC .1.Best Practice: Using DB2 Compression Feature in SAP Environment R3load 700 R3load Version 7.com | BPX . the COMPRESS option is used. You need to restart R3load manually to continue loading the rest of the data.boc. It loads all of the data into the table and then executes an offline reorg to compress the data. 4. In subsequent test migration or final migration: a. The amount of data to be sampled can be customized with environment variable DB6LOAD_SAMPLING_FREQUENCY and DB6LOAD_MAX_SAMPLE_SIZE.sap.2 Sample export via /ISIS/ZCOMP Tool Bernoullli sampling is an efficient sampling method that is currently supported in DB2. Enable compression on the new table and create the compression dictionary.00 and higher offers new options related to DB2 compression:  COMPRESS This is compatible with the option in R3load 640 if the database is on DB2 9.3. and build a n optimal compressed table on the target system. this option is ignored. Since every row in the table have an equal probability. It then executes a reorg to build a dictionary based on the sampled inserted data. please refer to SAP note 1058437. In order to create the scripts needed for migration.  SAMPLED R3load imports each nth row of the export file into the target table first.  COMPRESS_ALL R3load creates all tables with COMPRESS YES attribute. You can use the scripts to export a sample of data from the source system. and full_compress option provides optimal compression ratio with longest runtime. Select the table to be exported from the Candidates or Compressed category.

bpx.com | BOC .Best Practice: Using DB2 Compression Feature in SAP Environment Click on Export Tab.sap.sap.sap.sdn.com 31 . you will see the selected table was added in this category: SAP COMMUNITY NETWORK © 2009 SAP AG SDN .boc.com | BPX .

clp to run the script.com | BPX .The script will export to the current directory. -.MSTA.bpx.sap. For detailed information on Bernoulli sampling with /ISIS/ZCOMP tool."MSTA" tablesample bernoulli (3.5451207347586E+00).com | BOC .18.MSTA.Execute db2 -tvf <script>.Best Practice: Using DB2 Compression Feature in SAP Environment There are four function buttons in the Export category:  Remove Table: It removes the selected table from the export list.sap.sdn. export to SAPLRP.  Create WHR files for R3load Export: It creates the WHR files to export/import the Bernoulli sample with R3load.ixf of ixf modified by codepage=1208 messages SAPLRP.export_msgs. This is to prepare for the R3load-based approach. -.ixf.com 32 .  Create DB2 CLP Scripts: The scripts can be used to export/import the Bernoulli sample with native DB2 tools. Example (export script): -.txt select * from SAPLRP.sap. chapter 7. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .change the export directory if necessary.  Create Table File for Package Splitter: It creates a file with the names of tables to be sampled as input for the Package Splitter.boc. please check the redbook DB2 Optimization Techniques for SAP Database Migration and Unicode Conversion.

2 Rebuilding Compression Dictionary Rebuilding a dictionary requires an offline reorg of the table. it stays unchanged and is used for all incoming data.com | BOC . you can decide whether the existing dictionary needs to be replaced to achieve higher compression ratio. Post Compression Consideration 5. if the data in a table has changed significantly over time. However. the compression ratio is likely to get worse.1. Example: db2lrp> db2 "select pctpagessaved.sdn. We suggest you monitor the effectiveness of compression periodically as data evolves and reset the compression dictionary when needed.00000E+002 1 record(s) selected. 5. You can check the current compression information by querying the syscat.bpx. By comparing the PCPAGESSAVED from syscat.sap. db2lrp> db2 "reorg table saplrp.sap.Best Practice: Using DB2 Compression Feature in SAP Environment 5.sap.tables statistics view.s961 resetdictionary" DB20000I The REORG command completed successfully.tables where tabname='VBFA'" PCTPAGESSAVED PCTROWSCOMPRESSED ------------------------------------------------------------78 +1. This is not a concern if we already have good representatives of the data when the dictionary was built.tables with the following columns:  AVGROWSIZE: Average row size for compressed and uncompressed rows  AVGCOMPRESSEDROWSIZE: Average length (in bytes) of compressed rows  AVGROWCOMPRESSIONRATIO: Average compression ratio by row. Note: If the reorg is performed from db2 command line. pctrowscompressed from syscat.1 Monitoring the compression quality The effectiveness of compression depends on the data and the quality of the dictionary.1 Evaluating compression quality The compression statistics for table row compression are stored in syscat.com 33 . that is. Once the dictionary is created for the table. In Section 2.boc. This can be performed from db2 command line or DBAcockpit. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . the average uncompressed row length divided by the average compressed row length  PCTROWSCOMPRESSED: Compressed rows as a percentage of the total number of rows in the table  PCTPAGESSAVED: Approximate percentage of pages saved in the table as a result of row compression The statistics are updated as part of runstats processing. a runstat is needed to refresh the table statistics. whether through ADC or manually. Rebuild dictionary from db2 command line To rebuild the compression dictionary.com | BPX . you need to execute the REORG command with the RESETDICTIONARY clause.tables with the new estimated compression ratio. we have explained different methods to get a compression estimate on the table. 5.1.

7.sap.   For tablespaces created prior to DB2 9. The HWM on a reclaimable storage tablespace can be easily reduced with the ALTER TABLESPACE command.sap. To get around this problem. Click on the Compression ON/Off button on the Single Table Analysis screen. You can choose to leave the space in the tablespace for further growth. the space freed after compression is not released to the system automatically. By design. In some cases. and choose offline REORG.com | BPX . Please refer to the white paper DB2 9. To reclaim unused storage. you will need to move the tables to another tablespace with the DB6CONV tool and drop the tablespace afterwards. you can execute the ALTER TABLESPACE command to reduce the size of the tablespace. and the statistics are updated as well.boc.com | BOC . The table will be compressed based on a new dictionary. After compression. you need to take additional actions to lower the HWM first.Best Practice: Using DB2 Compression Feature in SAP Environment Rebuilding dictionary with DBAcockpit You can also reset the compression dictionary with DBAcockpit.  Tablespaces created with DB2 9. the HWM is held by a SMP extent (space map extent) that it can not be lowered. After the HWM is lowered.bpx.sdn. the HWM could be same or even higher if the reorg is performed in the same tablespace. the HWM can be lowered with a combination of db2dart and REORG command.7 New Features – Reducing the High Water Mark on SDN for more information. This can also be performed in the DBAcockpit-> Space->Tablespaces.7 are enabled with reclaimable storage. select option “RUN REORG in order to rebuild Dictionary”. or manually reduce the size of the tablespace after compression.2 Reclaiming space For DMS tablespaces. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .com 34 . the DMS table space can only be reduced to the HWM. IBM Technote: Lowering the High water mark of the tablespace provides detailed instruction on how to reduce HWM manually. 5.sap.

SAP COMMUNITY NETWORK © 2009 SAP AG SDN . auxiliary database files and database meta-data. With row compression only.sdn. In addition.sap. compression may affect backup performance negatively because of the tablespace fragmentation (explained in section 3. backup compression also compresses catalog tables.com | BPX .com 35 . backup performs faster when the size of the database is reduced. 6. the overall compression ratio for the database can be over 50%.0 IDES 159 GB 108 GB 29% 43% 18% 31.sap.3). or use DB6CONV to move the tables to another tablespace.boc.com | BOC . it is not recommended to use backup compression on a compressed database unless space saving is of high priority.0 1640 GB 890 GB 49% 33% 34% 45. you can follow the same steps to lower the HWM of the tablespace. DB2 index compression provides additional 10-20% savings.bpx.sap. To reduce tablespace fragmentation. In general.1 with SAP Banking 103 GB 41 GB 69% 37% 50% 59. the backup image can be compressed with the COMPRESS YES option in the BACKUP command. However the runtime is much longer.7%* SAP NetWeaver 7. reducing HWM after compression will also help you to get optimal backup performance because DB2 backup operation processes all pages up to the HWM as part of the backup image. Our test shows if the size of the database is reduced significantly with compression.9% SAP BW 7. the additional space saved through backup compression is very limited. LOB objects.3 Backup Performance As of DB2 V8. Reference numbers from SAP system SAP Customers using DB2 compression features have experienced significant reductions in the size of their databases. In addition to data and index compression.7% *The compression rate for SAP IDE system is relatively low because it contains many SAP-compressed cluster tables.Best Practice: Using DB2 Compression Feature in SAP Environment 5. In some rare cases. SAP ECC 6. In general. This problem will be addressed in future DB2 fixpaks. Test Scenario DB Size uncompressed DB Size compressed Compression Rate Data Compression Rate Index Storage Savings with data compression only Storage Saving with data and index compression.

boc.DB6: Using DB2 9 with SAP Software Note 905614 .7 New Features – Reducing the High Water Mark DB2 Optimization Techniques for SAP Database Migration and Unicode Conversion Row Compression in DB2 9.sap.com | BPX .DB2 9 data row compression for SAP BW 3.R3load options for compact installations Papers and Redbook Best Practice: Deep Compression Index Compression DB2 9. Part 1: Data compression in DB2 9 Enabling DB2 LUW 97's LOB Inlining in an SAP Environment DB2 Information Center SAP COMMUNITY NETWORK © 2009 SAP AG SDN .com | BOC .bpx.com 36 .DB6: R3load -loadprocedure fast COMPRESS Note 817709 .x Note 926919 – DB2 9 data row compression for SAP NetWeaver BI 2004s Note 1108956 –Large RIDs Note 1058437.sap.DB6: Using DB2 9 Row Compression Note 930487 .com/notes) https://service.sap.High water mark Note 906765 .sdn.Best Practice: Using DB2 Compression Feature in SAP Environment Related Content SAP Notes (http://service.com/sap/support/notes/# Note 980067 .DB6: DB6CONV: Complete version history Note 486559 .DB2DART: Reducing high water mark Note 362325 .sap.sap.DB6: Table conversion using DB6CONV Note 152531 .5: Analysis of a DSS Database Environment Deep dive into compression Introducing DB2 9.

sdn. code or methods suggested in this do cument.sap.Best Practice: Using DB2 Compression Feature in SAP Environment Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. and anyone using these methods does so at his/her own risk. SAP will not be held liable for any damages caused by using or misusing the information. Changes made based on this information are not supported and can be overwritten during an upgrade.sap. SAP responsible or liable with respect to the conte nt of this document.boc.com | BOC .bpx. including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP.sap. or seek to hold. You agree that you will not hold.com 37 . SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample.com | BPX . SAP COMMUNITY NETWORK © 2009 SAP AG SDN .

Sign up to vote on this title
UsefulNot useful