Skip to content
Download all

Before you install PostgreSQL, learn what you are installing. A running PostgreSQL server is three things working together: the processes, the memory they share, and the files on disk. You will find each of them on your own server in section 5, right after the install.

PostgreSQL 18 architectureClients connect to the postmaster on port 5432, which starts one backend process per connection. Each backend has local memory: work_mem, maintenance_work_mem and temp_buffers. All processes share shared memory: shared_buffers, WAL buffers and the commit status buffers. Background processes (checkpointer, background writer, io workers, walwriter, autovacuum launcher, logger, and the archiver when enabled) move data between shared memory and the files on disk: data files in base, WAL files in pg_wal, commit status in pg_xact, server logs in log, and the WAL archive outside the data directory.Backend processes: one per connectionLocal memory: each backend has its ownShared memory: every process can use itBackground processesFiles on disk: the data directory (PGDATA)starts one backend per connectionread and change databackground work on shared memorywrite changed pagesread pagesflush WALcopy full WAL filespsqlapplicationpostmasterlistens on port 5432, starts every processbackendclient 1backendclient 2backend...work_memsorts, hashesmaintenance_work_memtemp_bufferstemp tablesshared_bufferscached 8 kB data pagesWAL bufferschange records not yet on diskcommit status buffers (CLOG)did each transaction commit?checkpointerbackgroundwriterio workers(3 in PG 18)walwriterautovacuumlauncherloggerarchiver(off by default)base/data filespg_wal/WAL filespg_xact/commit statuslog/server logsWAL archiveoutside PGDATA
PostgreSQL 18 architecture. Dashed parts are off or outside the data directory by default.

Read it from top to bottom, one layer at a time:

  1. Clients (psql, an application) connect to the postmaster on port 5432.
  2. The postmaster starts one backend process for each connection. That backend runs the client's SQL until the client disconnects.
  3. Each backend has its own local memory for sorting, building indexes and temporary tables.
  4. All processes share shared memory: the cached data pages, the change records waiting for the WAL, and the commit status of recent transactions.
  5. Background processes do the work no client asked for: writing changed pages and WAL to disk, reading pages for backends, cleaning up old row versions, copying WAL to an archive, and writing the server log.
  6. Everything lasting lives in files on disk, in the data directory.

Sections 2.1, 2.2 and 2.3 take one layer each: processes, memory, storage.

Shared memory

starts one per connection

walwriter

checkpointer and
background writer

psql
(client)

postmaster
listens on port 5432

web app
(client)

backend
for psql

backend
for web app

shared_buffers
(cached data pages)

WAL buffers
(change records)

pg_wal
WAL files

base
data files

Read it from top to bottom. Clients connect to the postmaster, which starts a backend process for each one. Backends read and change data in shared_buffers, and write a record of every change into the WAL buffers. At COMMIT, that record is written to the WAL files on disk before the client gets "OK"; the walwriter also writes WAL in the background. The changed data pages are written to the data files later, by the checkpointer and the background writer.

Was this page helpful?

Thanks. Glad it helped.

Thanks for telling us. Email the instructor what was missing, or ask in class.