2. How PostgreSQL works inside
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.
The whole server on one page
Section titled “The whole server on one page”Read it from top to bottom, one layer at a time:
- Clients (
psql, an application) connect to the postmaster on port 5432. - The postmaster starts one backend process for each connection. That backend runs the client's SQL until the client disconnects.
- Each backend has its own local memory for sorting, building indexes and temporary tables.
- All processes share shared memory: the cached data pages, the change records waiting for the WAL, and the commit status of recent transactions.
- 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.
- 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.
How one change travels
Section titled “How one change travels”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.