IMS Pointers
IMS Pointers
Pointers in HD databases
Before looking in detail at how HD databases are stored and processed, you
need to become familiar with the pointers that are used in HD databases.
With hierarchical forward and backward pointers (HF and HB), each segment
in a database record points to both the segment that follows and the one
that precedes it in the hierarchy (except dependent segments do not point
back to root segments).
With physical child first (PCF) pointers, each parent segment in a database
record points to the first occurrence of each of its immediately dependent
child segment types.
With physical child first and last pointers (PCF and PCL), each parent
segment in a database record points to both the first and last occurrence of
its immediately dependent child segment types.
Page 1
With physical twin forward and backward (PTF and PTB) pointers, each
segment occurrence of a given segment type under the same parent points
both forward to the next segment occurrence and backward to the previous
segment occurrence.
Mixing pointers
When a segment contains more than one type of pointer, pointers are put in
the segment's prefix in a specific sequence.
Except for a few special cases, each prefix in an HD segment contains one or
more pointers. Each pointer is 4 bytes long and consists of the relative byte
address of the segment to which it points. Relative, in this case, means
relative to the beginning of the data set.
Several different types of direct-address pointers exist, and you will see how
each works in the topics that follow in this section. However, there are three
basic types:
Page 2
within a database record. However, because pointers are specified by
segment type, all occurrences of the same segment type have the same
type of pointer.
Page 3
When an application program issues a call for a segment, HF pointers are
followed until the specified segment is found. In this sense, the use of HF
pointers in an HD database is similar to using a sequentially organized
database. In both, to reach a dependent segment all segments that
hierarchically precede it in the database record must be examined. HF
pointers should be used when segments in a database record are typically
processed in hierarchical sequence and processing does not require a
significant number of delete operations. If there are a lot of delete
operations, hierarchical forward and backward pointers (explained next)
might be a better choice.
Four bytes are needed in each dependent segment's prefix for the HF
pointer. Eight bytes are needed in the root segment. More bytes are needed
in the root segment because the root points to both the next root segment
and first dependent segment in the database record.
Restriction
Page 4
that precedes it in the hierarchy (except dependent segments do not point
back to root segments).
HF and HB pointers must be used together, since you cannot use HB pointers
alone. The following figure shows how HF and HB pointers work.
HF pointers work in the same way as the HF pointers that are described in
Hierarchical forward pointers.
The backward pointers are useful only when all of the following are true:
Page 5
Forward to a dependent segment
Forward to the next root segment in the database
Backward to the preceding root segment in the database
Restriction
HALDB databases do not support HF and HB pointers.
With PCF pointers, the hierarchy is only partly connected. No pointers exist
to connect occurrences of the same segment type under a parent. Physical
twin pointers can be used to form this connection. Use PCF pointers when
segments in a database record are typically processed randomly and either
sequence fields are defined for the segment type, or if not defined, the insert
rule is FIRST or HERE. If sequence fields are not defined and new segments
are inserted at the end of existing segment occurrences, the combination of
PCF and physical child last (PCL) pointers (explained next) can be a better
choice.
Page 6
Four bytes are needed in each parent segment for each PCF pointer.
PCF and PCL pointers must be used together, since you cannot use PCL
pointers alone. The following figure shows PCF and PCL pointers:
Note that if only one physical child of a particular parent segment exists, the
PCF and PCL pointers both point to the same segment. As with PCF pointers,
PCF and PCL pointers leave the hierarchy only partly connected, and no
pointers exist to connect occurrences of the same segment type under a
parent. Physical twin pointers can be used to form this connection.
PCF and PCL pointers (as opposed to just PCF pointers) are typically used
when:
Page 7
On insert operations, if the ISRT rule of LAST has been specified, segments
are inserted at the end of all existing segment occurrences for that segment
type. When PCL pointers are used, fast access to the place where the
segment will be inserted is possible. This is because there is no need to
search forward through all segment occurrences stored before the last
occurrence. PCL pointers also give application programs fast retrieval of the
last segment in a chain of segment occurrences. Application programs can
issue calls to retrieve the last segment by using an unqualified SSA with the
command code L. When a PCL pointer is followed to get the last segment
occurrence, any further movement in the database is forward.
A PCL pointer does not enable you to search from the last to the first
occurrence of a series of dependent child segment occurrences.
Four bytes are needed in each parent segment for each PCF and PCL pointer.
PCF and PCL pointers are specified by coding the PARENT= operand in the
SEGM statement in the DBD as PARENT=((name,DBLE)). This is the SEGM
statement for the child being pointed to, not the SEGM statement for the
parent. Note, however, that the pointers are stored in the parent segment.
The figure following the DBD statement below shows the result of specifying
PCF and PCL pointers in the DBD statement.
DBD
SEGM A
SEGM B PARENT=((name.SNGL)) (specifies PCF pointer only)
SEGM C PARENT=((name.DBLE)) (specifies PCF and PCL pointers)
Copy
Page 8
With physical twin forward (PTF) pointers, each segment occurrence of a
given segment type under the same parent points forward to the next
segment occurrence.
Note that, except in PHIDAM databases, PTF pointers can be specified for
root segments. When this is done in an HDAM or PHDAM database, the root
segment points to the next root in the database chained off the same root
anchor points (RAP). If no more root segments are chained from this RAP, the
PTF pointer is zero.
When PTF pointers are specified for root segments in a HIDAM database, the
root segment does not point to the next root in the database.
You cannot use PTF pointers for root segments in a PHIDAM database.
PHIDAM databases only support PTF pointers for dependent segments.
With PTF pointers, the hierarchy is only partly connected. No pointers exist to
connect parent and child segments. Physical child pointers can be used to
form this connection. PTF pointers should be used when segments in a
database record are typically processed randomly, and you do not need
sequential processing of database records.
Four bytes are needed for the PTF pointer in each segment occurrence of a
given segment type.
PTF pointers are specified by coding PTR=T in the SEGM statement in the
DBD. This is the SEGM statement for the segment containing the pointer.
Page 9
Physical twin forward and backward pointers
With physical twin forward and backward (PTF and PTB) pointers, each
segment occurrence of a given segment type under the same parent points
both forward to the next segment occurrence and backward to the previous
segment occurrence.
PTF and PTB pointers must be used together, since you cannot use PTB
pointers alone. The following figure illustrates how PTF and PTB pointers
work.
Page 10
Note that PTF and PTB pointers can be specified for root segments. When
this is done, the root segment points to both the next and the previous root
segment in the database. As with PTF pointers, PTF and PTB pointers leave
the hierarchy only partly connected. No pointers exist to connect parent and
child segments. Physical child pointers (explained previously) can be used to
form this connection.
PTF and PTB pointers (as opposed to just PTF pointers) should be used on the
root segment of a HIDAM or a PHIDAM database when you need fast
sequential processing of database records. By using PTB pointers in root
segments, an application program can sequentially process database records
without IMS™ having to refer to the HIDAM or PHIDAM index. For HIDAM
databases, PTB pointers improve performance when deleting a segment in a
twin chain accessed by a virtually paired logical relationship. Such twin-chain
access occurs when a delete from the logical access path causes DASD
space to be released.
Eight bytes are needed for the PTF and PTB pointers in each segment
occurrence of a given segment type.
PTF and PTB pointers are specified by coding PTR=TB in the SEGM statement
in the DBD.
Mixing pointers
Page 11
Because pointers are specified by segment type, the various types of
pointers can be mixed within a database record. However, only hierarchical
or physical, but not both, can be specified for a given segment type.
The types of pointers that can be specified for a segment type are:
HF
Hierarchical forward
HF and HB
Hierarchical forward and backward
PCF
Physical child first
PCF and PCL
Physical child first and last
PTF
Physical twin forward
PTF and PTB
Physical twin forward and backward
Page 12
If PTR=HB is specified for a segment other than the root, PTR=T
and PTR=H cannot be specified for any of its children.
Page 13
Notes for Figure
1. These pointers are generated when you specify PTR=H on
the root segment.
2. If you specify PTR=H, usage is hierarchical (H); otherwise
usage is twin (T).
3. These pointers are generated when you specify PTR=T on
segment type C and PARENT=SNGL on segment type D
4. These pointers are generated when you specify PTR=T on
segment type C and PARENT=DBLE on segment type E
5. These pointers are generated when you specify PTR=T on
this segment type
Page 14