bdfd1m19Database Administration

Using Algorithms instead of Indexing

This method of reducing I/O is especially useful where some parts of a file are more frequently accessed than others. For example, it may not be efficient to index every date in a flight file when only the earlier dates are being accessed frequently.

You can code a mathematical function to translate the index key (for example, date) and then use TPFDF algorithm #TPFDB05 to locate the ordinal directly. Alternatively, you could use TPFDF user exit UWBD to define an algorithm of your own. See page *** for more information about creating user-defined algorithms.

Figure 50 shows an index file with each date pointing to a separate detail subfile:

Figure 50. Subfiles Accessed from an Index File


In Figure 51, the index file is replaced by a calculated value, which is passed to the #TPFDB05 algorithm to locate the ordinal directly.

Figure 51. Subfiles Accessed Using Algorithm #TPFDB05


Note:
Where an uneven distribution of LRECs is likely, user-defined algorithms can generate a better distribution. For example, where passenger names are being distributed alphabetically, there are a greater number of names beginning with S than with X.

The distribution will probably be very uneven if you use algorithms #TPFDB01, #TPFDB02, or #TPFDB03. However, if you define your own algorithm, you can accommodate this difficulty by creating extra ordinals for the more common characters. See *** for more information about user-defined algorithms.