DEV Community

m_aamir
m_aamir

Posted on

PostgreSQL Memory Architecture

PostgreSQL has two kinds of memory locations to store data: the shared memory area, and local memory area.

PostgreSQL Memory Architecture

Shared Memory Area

The shared memory area is used by all processes of a postgreSQL server. It is allocated when the server is started.

The shared memory area can be divided into sub-areas based on their function. The main sub-areas are described below:

  1. Shared pool buffer: this is where postgres loads pages and operates on them.
  2. WAL buffer: this is where WAL data is stored before being written to permanent storage.
  3. Commit log: stores the states of all transactions.
  4. Checkpointer
  5. Autovacuum
  6. Sub-areas for semaphores and locks for concurrency control.

Local Memory Area

This is unique to each backend process. It is used for query processing. It has 3 major sub-areas:

  1. work_mem: this area is used for sorting tuples by the ORDER BY and DISTINCT operations.
  2. maintenance_work_mem: used for maintenance operations.
  3. temp_buffers: used for storing temporary tables.

References:

https://www.interdb.jp/pg/pgsql02.html

Top comments (0)