Linux Read Ahead

Mark Wong
Mark Wong

Having a sufficiently sized read-ahead buffer can significantly increase a storage device's sequential read performance without adversely affecting other access patterns.

These are the Linux default settings for /sys/block/dm-0 read-ahead:


The read-ahead value on the database device could achieve increased performance by increasing this value. The optimal value depends on the storage system, with larger disk arrays benefiting from higher values, particularly for large sequential scans. We recommend increasing the value to 8192 or perhaps even 16384. These values have been determined from a Postgres community testing effort over the years.

Here is an example of checking and setting readahead values:

# /sbin/blockdev --getra /dev/block/dm-0
# /sbin/blockdev --setra 8192 /dev/block/dm-0

Care is some care is required because excessive readahead can slow random I/O.

Was this article helpful?

0 out of 0 found this helpful