postgres/postgres
Systems
PostgreSQL's backend (src/backend/) is organized into a layered set of subsystems. From the bottom up:
- Storage — buffer pool, file manager (
md), shared memory, lock managers. The substrate everything else sits on. - Access methods — heap (table storage), B-tree, GIN, GiST, SP-GiST, BRIN, hash. The Table Access Method API and Index Access Method API.
- MVCC and transactions — XID assignment, snapshots, the proc array, CLOG, multixact, visibility rules. PostgreSQL's defining concurrency model.
- WAL and recovery — write-ahead logging, checkpoints, crash recovery, archive/restore, point-in-time recovery.
- Catalog — system catalogs (
pg_class,pg_attribute, etc.), the bootstrap process, sys cache, relcache. - Parser — bison grammar, parse analysis, the
Queryrepresentation. - Planner — path enumeration, cost estimation, plan generation, GEQO.
- Executor — pull-based plan node evaluation, expression interpreter, JIT, parallel query.
- Replication — streaming and logical replication, WAL senders/receivers, replication slots, publications/subscriptions.
- Postmaster and process model — the supervisor, fork dance, auxiliary processes, background workers.
- Utilities — memory contexts, error reporting, GUC, statistics collector, foreign data wrappers, partitioning machinery.
The diagram in overview/architecture.md places these in context. The pages here go deeper: each names the relevant source files, describes the data flow, and points at where to start reading if you want to modify the subsystem.
How the subsystems relate
graph TD
subgraph "Front door"
Postmaster["Postmaster"]
Backend["Backend (postgres.c)"]
Postmaster --> Backend
end
subgraph "Query pipeline"
Parser
Planner
Executor
Backend --> Parser --> Planner --> Executor
end
subgraph "Engine"
AM["Access methods"]
Storage["Storage<br/>(buffer, file, lmgr)"]
WAL["WAL"]
Catalog
MVCC["MVCC<br/>(xact, snapshot, procarray)"]
Executor --> AM
Executor --> Catalog
Executor --> MVCC
AM --> Storage
AM --> WAL
Storage --> WAL
Catalog --> AM
end
Replication["Replication"] --> WAL
Postmaster --> ReplicationAlmost every subsystem has dependencies that go in both directions. The parser reads the catalog. The catalog is implemented on top of access methods. Access methods log through WAL. WAL is consumed by replication. The postmaster supervises everything. Read the system pages in roughly the order above and the dependency graph stays manageable.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.