Chapter 6. Partition initialization
7.1 Choosing the type of partition selection
HALDB allows you to choose between two types of partition selection. Key range partitioning assigns a range of keys to each partition. Alternatively, you may write a partition selection exit routine that uses its own criteria for assigning keys to partitions. In both types, only the key of the root segment is used to assign a record to a partition. Both types may be used with any HALDB database type. These are PHDAM, PHIDAM, and PSINDEX.
7.1.1 Key range partitioning
Key range partitioning is usually preferred. With key range partitioning, a high key is assigned to each partition. The partition holds all records with keys higher than the previous partition and up to the value of its high key.
Key range partitioning is the simpler method to implement because you do not have to write an exit routine. You only have to assign a high key to each partition. In PHIDAM and PSINDEX databases, the records are in key sequence across the entire database. This makes them compatible with HIDAM and non-HALDB secondary index databases. When a partition selection exit routine is used for PHIDAM or PSINDEX databases, records are in key sequence within a partition, but not across partitions. This would make these databases incompatible with HIDAM and non-HALDB secondary index databases. Applications that require database records to be in key sequence would not function correctly.
IMS is aware of the impact of the addition of partitions, their deletion, or changes in their boundaries. IMS can determine which partitions require initialization after these changes. Figure 7-1 illustrates this. In the figure, the change of the high key for partition B from 40000 to 50000 would require the movement of records from partition C to partition B. Both of these partitions would have to be unloaded before the change. Both would have to be initialized and reloaded. IMS sets the
partition init needed
flag for both partitions when the high key for partition B is changed. This is not true when you use an exit routine. The logic of the exit routine determines which partitions require initialization after these changes. You are responsible for understanding this and initializing the correct partitions.Figure 7-1 Key range partitioning
A B C D
We recommend that you assign a high values key to a partition. If you do not and if an application attempts to insert a root with a key higher than the highest key defined, the call will receive an FM status code. Most applications are not coded to handle this status code. A high values key is one with X’FF’ for each byte. There is a case where key range partitioning will require the addition of partitions or changes to their key ranges over time. This occurs when records that are added to the database have increasing keys. Examples include keys created by incrementing the previous key and keys based on dates or times. As records are added, you will need to split the last partition into multiple partitions. As records are deleted, you may want to consolidate partitions containing lower values.
7.1.2 Partitioning with an exit routine
You may use a partition selection exit routine to assign records to partitions. Only the key of the root segment is available from the database record for the exit routine. Since writing and maintaining the exit routine increases your
responsibilities, we recommend that you use an exit routine only if key range partitioning does not meet your needs.
An exit routine would allow you to assign records to a partition based on a value other than the high order part of the key. Figure 7-2 illustrates a use of an exit routine. In this figure a warehouse code is in the fifth and sixth bytes of the eight-byte key. The partition selection exit routine assigns records to partitions based on the warehouse code. The installation plans on processing data by warehouse. By isolating data for a warehouse in one partition, they can simplify the processing and improve its performance.
Figure 7-2 Partitioning with an exit routine
The HALDB Conversion and Maintenance Aid product includes an exit routine that will do this kind of partition selection. If you use it, you do not have to write the exit routine. You only have to specify what part of the key is to be used and the values for each partition.
xxxx01xx xxxx02xx xxxx03xx xxxx04xx
Key format = xxxxnnxx
Another use of a partition selection exit routine is to isolate some database records because of their special characteristics. For example, the sizes of most records in a PHDAM database may be fairly uniform, but others may be much larger. These unusually large records could otherwise cause space use problems within partitions. If the keys of these large records are known, an exit routine could recognize their keys and place them in a partition with different space characteristics. The partition might have many fewer records spread across the same amount of space. It might even have its own specialized randomization routine.
In the last paragraph in 7.1.1, “Key range partitioning” on page 80, we discuss a database whose key values continued to increase. With key range partitioning this could present a problem. You would have to continually adjust the partitions. An exit routine might solve this problem. If there is no need for key sequence processing, an exit routine could distribute the records across partitions evenly. For example, it might assign the records based on the low order part of the key. Then each partition would always receive a consistent percentage of the records. Databases whose records must be processed in key sequence must use key range partitioning. Typically, a partition selection exit routine would assign records such that moving from one partition to the next might cause a decrement in the key value. The keys are sequential within the partitions but not from one partition to the next. This may have an impact on the application if it expects the keys to always increase. Records in HIDAM databases and non-HALDB
secondary indexes are always in key sequence. When they are migrated to PHIDAM or PSINDEX do not use a partition selection exit routine unless you are sure that key sequence processing is not required.