2. Process and Memory Architecture
A running PostgreSQL instance consists of multiple processes and memory structures that work together to execute queries, manage concurrent connections, and access database storage.
PostgreSQL uses a process model rather than a thread model. This design dates back to the development of PostgreSQL in the early 1990s. At that time, process-based concurrency was practically the only viable choice because POSIX threads had not yet become a standardized and reliable technology.
By maintaining this architecture, PostgreSQL continues to provide the following benefits:
-
Robust Isolation: Since each backend process operates independently, a crash in a specific session does not cascade to the rest of the system.
-
OS-Level Memory Management: Memory spaces are strictly partitioned between processes to ensure isolation. Furthermore, the operating system reliably reclaims resources when a process terminates.
This chapter explains the process and memory architectures that form the runtime environment of PostgreSQL. It first describes the Postmaster process, backend processes, and background processes, and then explains the shared and local memory structures used by these processes.