# PostgreSQL

PostgreSQL is an open-source relational database with a process-per-connection model: when a client connects, the server forks a dedicated *backend* to handle it. Backends share access to a large in-memory cache called the **shared buffer pool**, sized via `shared_buffers`. The pool stores recently-read 8 KB *data pages* (PostgreSQL's on-disk unit, distinct from a Linux memory page) so subsequent reads avoid disk.

When a backend needs a data page that isn't in the buffer pool, it calls `StrategyGetBuffer` to pick a slot — either an empty one or a victim to evict. That selection is protected by a single global [[spinlock]]. The design assumes the critical section is tens of nanoseconds and the holder is gone before anyone notices.

## Notable interactions covered in the wiki

- [[linux-7-postgres-regression]] — Linux 7.0 removed `PREEMPT_NONE` (see [[linux-preemption-models]]), letting the scheduler preempt a backend mid–page fault while it holds the `StrategyGetBuffer` spinlock. On a 96-vCPU Graviton4 with 120 GB `shared_buffers` and 4 KB pages, every other backend spins on a held lock; throughput halves. Workaround: enable [[huge-pages]].
- [[linux-kernel-pgit]] — pgit ingests Linux kernel git history into PostgreSQL so it's queryable as SQL. Different angle on the same database.

## Repo

<https://github.com/postgres/postgres>
