Thursday, January 20, 2005

Blocking, Sequential Only, and the Effect on an RPG Program

IBM eServer iSeries Support: Software Technical Document : 10064916

All high-level language programs (HLLs) use blocking at certain times and use single record I/O at other times, based on program specifications. Because blocking takes less system resources to perform a single I/O, a program that blocks performs better and uses less system resources. The default for the HLL uses record blocking if opening a file for output only (write) or input only (read). The programmer is expected to override the file or use larger blocks if the default is not appropriate. The HLLs do single I/O if files are opened for both input/output or update/delete. Blocking works well only if one reads many records sequentially because the block of records read are from some position in the file and the next N records. If one is going to position randomly within the file (CHAIN or set lower limit (SETLL) in RPG) and then read only two records, blocking may actually be a waste of system resources as the read after the random position reads a single record; however, the next read reads a block of records and the program reads only one.

The parameter on the override command that expresses the intent to block is sequential only (SEQONLY) to emphasize that the intent is to read some number of records in a row (you choose the number). Sequential only does not preclude the program from doing random positioning; however, remember the system reads an entire block of records when the second READ is run after the position (the first read accesses a single record only).

http://www-912.ibm.com/s_dir/slkbase.NSF/0/d6738e1cd37e1f33862565c2007cef79?OpenDocument

No comments:

Post a Comment