In a DB Server, data is persisted to disk . Disk-based storage is advantageous because :
it can survive downtime , such as power outages,
its cost per megabyte is much less than that of RAM.
However, disks are much slower than RAM. For this reason, DB Server uses the RAM as a data cache .
When DB Server starts, very little physical memory is used, as no data has been requested. As data is requested by applications, DB Server reads the data from disk and stores it in RAM. Data is then supplied directly from RAM to satisfy the request.
When subsequent requests are made for the same data, there is no need to read it from the disk. It is already loaded into RAM. Because RAM is faster than disks, the subsequent requests perform better than the first request.
When the cache fills and new data is requested, which must be retrieved from disk, the older data in the cache is aged out. This means that the data that has been requested recently will be the first to be removed from RAM.
Due to this algorithm, the server will be able to keep commonly used data in memory for long periods, while flushing occasionally requested data as new data needs to be loaded into memory.