8. Buffer Manager

Beta Version: Version 19's new buffer page lock mechanism is not supported.

When processing data, backend processes do not directly operate on data in persistent storage. Instead, they load the data into shared memory and operate on it there. This design is adopted by all RDBMSs because memory access is significantly faster than access to persistent storage.

The buffer manager manages data transfers between shared memory and persistent storage. The PostgreSQL buffer manager is a collection of functions that allows backend processes to transparently operate on data stored in persistent storage through shared memory. Its efficiency significantly affects DBMS performance, and the PostgreSQL buffer manager is designed to operate efficiently.

Figure 8.1. Relations between buffer manager, storage, and backend processes.

The performance of the PostgreSQL buffer manager has improved steadily over successive releases:

  • Version 8.1 (2005) introduced an enhanced page replacement algorithm. o+ Version 9.6 (2016) replaced the spinlocks that protected internal state changes with atomic operations.
  • Version 18 (2025) introduced asynchronous I/O to read blocks from storage more efficiently.

This chapter describes the PostgreSQL buffer manager. The first section provides an overview, and the subsequent sections describe the following topics:

  • Buffer manager structure
  • Buffer manager locks
  • Buffer management mechanisms
  • Asynchronous I/O in PostgreSQL
  • Dirty page flushing