bdfd1m1cDatabase Administration

Block Indexing

Block indexing considerably reduces I/O processing when files are being read but can make updating slower.

The prime block of a block index subfile contains technical LRECs (TLRECs), which are maintained internally by the TPFDF product.

As you can see in Figure 62, each index TLREC contains the following:

Figure 62. Index TLREC


Note:
Not all TLRECs hold the same amount of user data. Use the DSECT to define how much data a TLREC can hold.

To avoid having to look at every LREC in every block, the TPFDF product stores indexing data in the TLRECs. The TLRECs hold data extracted from the first LREC in each overflow block.

The TPFDF product compares each TLREC with the LREC keys that the application program is searching for. If the LREC keys that the application program is searching for are less than or equal to the keys of the first LREC in the current block, the TPFDF product looks back to the previous block to find the matching LREC.

Figure 63 shows an example of this process. In this example, the application program is searching for the key, SMITH. The search process is as follows:

(1) The TPFDF product looks at the TLREC for overflow block 1 (DAVIDSON). The key held there is less than SMITH.

(2) The TPFDF product looks at the TLREC for overflow block 2 (FREEMAN). The key held there is less than SMITH.

(3) The TPFDF product looks at the TLREC for overflow block 3. The key held there is equal to SMITH .

(4) The TPFDF product searches the previous overflow block (2) for SMITH and finds the first instance of it.

Figure 63. Block Indexing


Implementing Block Index Support

To implement block index support, set global set symbol &SW00SKE in the file DSECT macro definition to the size, in bytes, of the key fields of the LRECs. If there are different types of LRECs in the file, set &SW00SKE to the longest key field.

If you update an existing file to use block indexing, the change is not immediate. The database administrator must first reassemble the DBDEF macro. The TPFDF product adds block index support LRECs to the file when LRECs are deleted from the file or when the file is packed and closed.

Note:
The TPFDF product uses X'02' as the LREC ID in LRECs that it uses for block index support. Ensure the value for global symbol &SW00TQK is greater than X'02'.

Block Index File Characteristics

Block index files have the following characteristics: