The
server maintains a cyclic data cache. It is cyclic in that the oldest entries
will be overwritten if the cache gets full. The server can respond very fast,
when cached data is accessed, since no access to the disk is involved.
Both the size and permanence of the cache as well as the strategy used to fill
the cache can be configured. The cache size is the number of megabytes used by
the server to cache regular data. Permanence is based on the following choices:
Either the cache is visible in a file, which contents survive a server restart,
or the cache exists in the server's address space, resulting in the cache
contents being volatile and gone, when the server stops.
Often, these options are referred to as hard disk cache und RAM cache,
respectively. To call a permanent cache, visible as a hard disk file, hard disk
cache, is quite sensible. Calling an invisible cache RAM cache might also seem
sensible, but is not technically correct. The operating system does not reserve
RAM space for volatile caches, but uses the swapspace (UNIX) or the pagefile
(NT). These are hard disk areas, which can be used by single processes as part
of their private address space. If sufficient RAM space is available, these
data will normally be in RAM. If not, access to the volatile cache will also
cause access to the hard disk. The permanent cache works similar. It is stored
in a file, but data once read from the cache will also be in RAM, provided
enough RAM is available. Whether the cache is in RAM or on the hard disk,
depends less on being permanent or not, but on the cache size and computer
resources. You cannot expect a volatile data cache of 200 MB to fit in 64 MB of
RAM. On the other hand, a permanent data cache of 200 MB might very well fit in
RAM completely, if the computer is equipped with e.g. 2 BG RAM.
A volatile cache is faster than a non-volatile cache, because the server
does not need to log transactions in the journal. If the server crashes due to
a power failure, the cache contents is completely lost. As opposed to a
volatile cache, the server would have to repair a permanent cache using the
journal. It takes time to maintain the journal while the server is running.
Before you configure a large volatile cache, you should increase the size of
the swapspace or pagefile accordingly.
The server will use a volatile data cache of 8 MB by default, if no data cache
is configured by the administrator.
The strategy used to fill up the cache depends on the parameters
rtrack, atrack, rahead (see section "Server
parameters" on page 125).
Note: In version 2.3 the server will only read 64 KB of the first chunk to the cache, even if the chunk size is set to a greater value. This bug will be fixed with the first patch. Up to then, reading larger areas into the cache can be forced with a high value for rahead.