Prefetching and buffering records

You can improve xfServer performance by prefetching and buffering records.

The prefetch feature improves sequential READS performance. This feature enables the client to prefetch sequential records from the server and store them in a buffer until they are needed. Prefetching is used with files of any type that are opened in input mode, with relative files that are opened in update mode, or with ISAM files that are opened in update mode and use the LOCK:Q_NO_TLOCK option.

Prefetching is not allowed in the following instances:

If you use prefetching in either of these cases, a “Sequential read caching error” ($ERR_SEQRDS) will occur. If this happens, immediately try doing a keyed READ to reset your current position.

Tip

If you currently have Q_NO_LOCK set and wish to use prefetching, you can set system option #55. This automatically maps READS with LOCK:Q_NO_LOCK to READS with LOCK:Q_NO_TLOCK, so that you can take advantage of prefetching without having to alter your code. See system option #55 for details and restrictions.

Buffering records improves sequential WRITES and PUTS performance. This feature enables the client to buffer sequential records waiting to be written to the server and then write them all at once, which improves file loading performance. Buffering is used with relative and sequential files that are opened in output or append mode (WRITES), and with stream files that are opened in output or append mode (WRITES or PUTS). Buffering does not take place when WRITES is used with the GETRFA option.

Both prefetching and buffering are controlled by the SCSPREFETCH environment variable. By default, prefetching/buffering is off. To turn these features on, set SCSPREFETCH on each client machine to a value between 1 and 32. This indicates the size of the buffer in kilobytes (e.g., a value of 4 results in a buffer size of 4096 bytes). To turn prefetching off, set SCSPREFETCH to 0. You can enable or disable this features on a file-by-file basis by using the SETLOG routine to set or clear SCSPREFETCH prior to the OPEN statement.

Note

For ISAM files, you can further improve performance by using the /bufstore option in the OPTIONS qualifier on the OPEN statement to buffer records on a STORE when system option #36 is not set.