DEV Community

Cover image for The Internals of PostgreSQL: Chapter 2: Process and Memory Architecture
Hasnain Somani
Hasnain Somani

Posted on

The Internals of PostgreSQL: Chapter 2: Process and Memory Architecture

This post summarizes Chapter 2 of the book "The Internals of PostgreSQL".
Postgre SQL is a relational database management system that works on client / server multi-process architecture. It consists of a single host, and various types of processes work together in postgreSQL to manage a database cluster.
The PostgreSQL server is a parent process that monitors the entire database cluster: It starts background processes, allocates shared memory, and awaits client connections. The server communicates on a specific network port (Default: 5432), and can run multiple instances on the same host by using different port numbers.
Postgres Processes are the backend processes spawned by the server. Their job is to handle incoming queries from clients that are connected. The communication between the client and process is done through a TCP connection, which eliminates as soon as the client disconnects. Every backend process operates on a single database, and the parameter "max_connections" determines the maximum number of concurrent client connections. The default value to it is 100.
Background processes handle various tasks such as Background writer, checkpointer, autovaccum, WAL Writer, and so on. All these functions are discussed in the upcoming chapters.
The memory architecture in PostgreSQL is simple: Local memory areas are allocated by each backend process, and a shared memory area is used by all processes of the postgreSQL server. In addition, PostgreSQL allocates memory for access control mechanisms, transaction processing, and other purposes. The details of both the local memory area and the shared memory area will be discussed in upcoming sections.
In a nutshell, PostgreSQL has a multi-process architecture: the server is the parent process, and backend processes handle client queries. It employs both local and shared memory areas to helo manage data and provide concurrency control.

Top comments (0)