DEV Community

Haseeb Ashraf
Haseeb Ashraf

Posted on

Process and Memory architecture in PostgreSQL

The architecture of PostgreSQL is such that it is a client/server type relational database management system and has a multi-process architecture that runs on a single host.

A PostgreSQL server is a collection of several processes cooperatively managing one database cluster that contains the following types of processes:

  • A postgres server process is a parent of all processes related to a database management system.

  • Every single backend process is responsible for managing all queries and statements that are generated by any connected client.

  • Different background processes help with processes of each feature for the database management system.

  • The replication associated process is responsible for performing the streaming replication process.

  • Lastly, the background worker process, can work on any processing that is demanded by the users.

A postgres server process starts up by executing the pg_ctl command with the start option. Next, it allocates shared memory, begins various background processes, starts a few other necessary processes and waits for a connection request from any online clients. A backend process is started whenever it receives a connection request from a client.

A backend process starts by the postgres server process and handles all queries issued by a connected client. It uses a TCP connection to communicate with the client and then terminates when the client is disconnected. As a backend process is allowed to only operate a single database, the client has to specify explicitly the database they want to use when connecting.

Now let's talk about the memory architecture of postgreSQL.

The memory architecture of postgreSQL can be classified into two major classes:

  • Local memory area - this is assigned by each backend process for its own use.

  • Shared memory area - this is used collectively by all the processes running on a PostgreSQL server.

In addition to these, PostgreSQL also allocates various memory areas as mentioned below:

  • Sub areas for the various access control mechanisms.

  • Sub areas for various background process e.g. autovaccum and checkpointer.

  • Sub areas for transaction processing such as two-phase-commit and save-point.

This was a short summary of the memory and process architecture of PostgreSQL.

Top comments (0)