Architecture of PostgreSQL
Learn about the high level architecture of PostgreSQL.
To understand how PostgreSQL stores and retrieves data, it’s important to understand its underlying architecture.
Key components of the PostgreSQL database
The architecture of PostgreSQL includes three major components: the client, the server process, and the database files.
Client: This refers to any program that requests data retrieval or storage with the PostgreSQL database.
Server: Server processes manage all the data stored in PostgreSQL databases. It interacts directly with database files to read and write their data.
Database files: These make up the physical storage for all the data in a PostgreSQL database. They contain information about each table, index, and other database components.
Tablespace
A tablespace is a location on a disk where the database system stores objects like tables, indexes, and other related files. When a database is created, a default tablespace is specified, and all database objects are created in this tablespace unless otherwise specified.
Tablespaces provide a way to organize database objects and manage disk space efficiently. For example, we can create a tablespace on a separate disk partition or drive to improve performance, or create a tablespace with a specific backup policy.
PostgreSQL also provides a special tablespace called pg_global
, which is used to store shared system catalogs that are accessible to all the databases in a PostgreSQL cluster. By default, all system catalogs are stored in the pg_global
tablespace.
Data flow
The use of transactions controls the flow of data in PostgreSQL. Transactions are a set of SQL commands executed as a unit; either all commands succeed, or none is executed. This makes it possible to ensure the consistency of the data in the database.
Each transaction has an associated transaction ID, which is used to identify it when it’s committed or rolled back. If a transaction is aborted (for example, because of a power failure), its effects are undone, and the database is restored to its state before the transaction began.
The flow of ...