Force Write

Having records available to downstream processes can be an issue when processing data sequentially, particularly with small record formats. RPG wants to perform record blocking for any file processed sequentially and will defer writing the data record to disk until the control block boundary is reached. This is highly desirable for batch applications where maximum throughput is required and asynchronous processing helps performance considerably.

But, it is not always a good thing in an interactive environment, to buffer the data record and defer the write. There are several methods available to force the record to disk. One common method is to change the physical file, CHGPF FILE(ISDKEY) FRCRATIO(1), which will cause applications using the file to immediately put the data record to disk. Changing the force/write ratio on the physical file may not be the best thing to do to a file, for performance reasons. Though the force write ratio will cause the data record to be written to the file, it also will force the associated pages in memory to be written to disk. Multiple disk writes can be a significant performance issue over a volatile file.

Alternatively you can perform a file override prior to opening a data file in a program. OVRDBF FILE(ISDKEY) SEQONLY(*NO) This will turn off record blocking for the file within the application itself. The same may be accomplished by specifying the BLOCK(*NO) keyword on the F-Spec in the RPG program.

Either of these options, turning off the record blocking, will perform generally perform better than changing the force/write ratio on the file itself. In releases of OS/400, OS/5, beginning with V5R2, there is another method of pushing the data record to the disk file without the overhead associated with FRCRATIO. The operation FEOD(N) gives the application the capability of determining when the data will be written to disk.

Depending on the application requirements, FEOD(N) may be used to force a record to disk after each WRITE, or after 10 records, or after a number of records based on a formula based on the rules of the application. If there is a necessity to write the associated pages from memory to disk, FEOD without the N operation extender will force the associated pages to disk.