next up previous
Next: SCSI vs. IDE Up: PostgreSQL Hardware Performance Tuning Previous: Multiple Disk Spindles

Disk Drive Cache

Modern disk drives have both a read and write cache. The read cache keeps recently requested disk blocks available in disk memory. The write cache holds write requests until they can efficiently be stored on the disk platters. You might relialize this could be a problem -- what if the drive loses power while it is holding write data that hasn't yet been written to the disk platters? Some disk drives, and RAID controllers, have a battery-backed write cache that keeps the data safe and writes it to the disk platters when full power is restored. However, most drives do not have this feature, and are therefore unreliable.

Fortunately, you can turn off the write cache in most drives. SCSI drives typically have the write cache turned off. IDE drives usually have the write cache turned on, but can be turne off with an operating system command link hdparm -W0, sysctl hw.ata.wc = 0, or scsicmd. However, some IDE drives will report that their write cache is turned off, but still use it and remain unreliable. It is difficult to fine out which drives are lying without extensive testing.

Because PostgreSQL writes the write-ahead log to disk on every transaction commit using fsync(), and waits for that write to complete, users will see a huge performance boost if a write cache is used. Therefore, for performance and reliability, it is ideal if PostgreSQL can use a battery-backed write cache.


next up previous
Next: SCSI vs. IDE Up: PostgreSQL Hardware Performance Tuning Previous: Multiple Disk Spindles
Bruce Momjian
2006-04-05