Converting tables from growth-based to range-based partitions
You can convert the partitioning scheme of a table from partition-by-growth (PBG) to partition-by-range (PBR) with minimal impact to your applications.
About this task
You can alter the partitioning scheme of a table with growth-based partitions (in a PBG table space) to use range-based partitions. The table space for the table is converted to PBR with relative page numbers (RPN). The conversion is usually a pending definition change that is materialized by a subsequent REORG.
If the PBR table space is defined with fewer partitions than the PBG table space, the excess partitions of the PBG table space are dropped, and information about the deleted partitions is deleted from catalog and directory tables.
The conversion process handles any existing non-partitioned indexes on the table. However, Db2 does not change any aspects or attributes of those indexes, so you might want to create partitioned indexes on the table after completing the conversion.
- When to convert tables from PBG to PBR
-
PBG and PBR universal table spaces (UTS) are both strategic table spaces types for Db2 for z/OS tables. PBG table spaces are the default UTS type, and most conversions to UTS result in PBG table spaces.
Tip: PBG table spaces are best used for small to medium-sized tables. If you expect a table to grow much larger than the 64 GB, consider using a partition-by-range (PBR) table space instead.When a table in a PBG table space grows too large, several drawbacks can begin to arise, including the following issues:- Insert and query performance degradation, which is perhaps the most important factor suggesting that conversion is required. Such performance degradation can have many causes, but for large tables in PBG tables spaces, the size of the table space is often one of the major causes.
- Difficulty regaining clustering of the data (which requires a REORG of the entire table space).
- Problems associated with very large non-partitioned indexes, because partitioned (partitioning and DPSI) indexes are not supported for tables in PBG table spaces. For more information, see
- Lack of partition parallelism support for utilities.
- Limited support for partition-level utility operations.
If you encounter these issues for tables in PBG table spaces, consider converting them to PBR.
- Requirements for converting tables from PBG to PBR
-
A table can be converted from PBG to PBR if the following conditions are met:
- The high limit key for the last partition requires MAXVALUE for ascending key columns or MINVALUE for descending key columns to avoid the data being discarded during the subsequent online REORG execution.
- If the table to be converted is defined with DATA CAPTURE CHANGES, and the data sets of the table space are defined, the number of partitions for the range-partitioning scheme must not be less than the maximum number of partitions for the PBG table space. This requirement avoids a situation where IFCID 0306 is unable to decompress log records associated with deleted partitions because the compression dictionaries no longer exist.
- The data sets for the table space and indexes must be associated with a DFSMS data class that is specified with extended format and extended addressability.
- The table identified by table-name to be altered must:
- Be a table that exists at the current server
- Be in a complete state if the alteration is a pending change
- Not be a catalog or directory table
- Not be a created global temporary table
- Not have table OBID = 1
- Not contain an XML column
- Not be involved in a clone relationship
- Not be defined with ORGANIZE BY HASH
- Not be an accelerated table
- Not contain a LOB column
- The containing table space of the altered table must follow these rules:
- Be a partition-by-growth table space
- Not have unmaterialized pending changes
Procedure
To convert an existing table in a PBG table space to use range-based partitions, complete the following steps: