User Tools

Site Tools


how_to:database_disk_caching

Database & Disk Caching

Disk Caching

One key point is that, like all other high-end databases, PostgreSQL should not be run on a server with disk level write back caching. With write back caching, the disk will report data as being written to disk when it is still in the disk's cache memory. If the power then fails, this data is lost and can cause database corruption. As long as the database server really knows when the data has been written to disk, power failure will not cause database corruption as it can be automatically recovered after a power failure.

High-end RAID controllers often contain a battery backed write cache (BBWC) - in this case, if the power fails, the cached data is held in battery powered memory until the power is restored. After power is restored the cached data will be written to disk. In this case, using write back caching through the BBWC is perfectly safe (as long as power is not left off for so long that the batteries run down).

It is slightly less safe, but still usually OK, to have a UPS with automated shutdown of the PC. You still have to ensure that the PC is not just turned off without shutting down properly.

If you don't have either of these facilities, then make sure you turn off write-back caching in Windows. (Note that 'Server' versions of Windows will usually have write-back caching disabled by default, because they often store critical data and run database servers, and 'Desktop' versions of Windows will usually have write-back caching enabled by default, because their data is usually less critical, and speed is considered more important than reliability).

Exactly how you turn off write-back caching depends on your version of Windows, and the disk controller.

The instructions below are for Windows 7 with standard SATA disks

  1. Go to the 'Device Manager' in Windows. In Windows 7 this is via Control Panel → System → Device Manager
  2. Under Disk Drives find the hard disk that VPOP3 is installed on, and right-click it and choose Properties
  3. Go to the Policies tab. Turn off Enable write caching onthe device and press OK
how_to/database_disk_caching.txt · Last modified: 2018/11/14 10:45 by 127.0.0.1