PostgreSQL in Practice
PostgreSQL Architecture
PostgreSQL 18 uses a process-per-connection server around shared memory, durable relation files, catalogs, and WAL. That architecture makes session count, cache behavior, checkpoints, and background maintenance application-visible operational concerns.
- The postmaster accepts connections and supervises child processes.
- Shared buffers mediate database-page access.
- Catalogs are ordinary, transactionally visible relations.
- Relation forks separate concerns.
- WAL decouples commit durability from heap-page flushing.
- Auxiliary processes protect liveness and operability.
| Layer | Responsibility | Operational consequence |
|---|---|---|
| Backend | parse, plan, execute, session state | pool sessions; avoid unbounded connection admission |
| Shared buffers | shared page cache and dirty state | inspect workload and I/O before changing size |
| Relation files/forks | heap, index, FSM, VM, unlogged initialization | use SQL/catalog tools, never manipulate files |
| WAL/checkpoint | durability and restart frontier | observe WAL rate, checkpoint I/O, flush latency |
| Workers | vacuum, archive, replication, parallel work | reserve capacity and alert on stalled work |
SELECT version();
SELECT name, setting, unit, source, sourcefile
FROM pg_settings
WHERE name IN ('shared_buffers','max_connections','checkpoint_timeout');
SELECT backend_type, count(*)
FROM pg_stat_activity
GROUP BY backend_type ORDER BY backend_type;