Open-Source Wikis

/

PostgreSQL

/

Systems

postgres/postgres

Systems

PostgreSQL's backend (src/backend/) is organized into a layered set of subsystems. From the bottom up:

  1. Storage — buffer pool, file manager (md), shared memory, lock managers. The substrate everything else sits on.
  2. Access methods — heap (table storage), B-tree, GIN, GiST, SP-GiST, BRIN, hash. The Table Access Method API and Index Access Method API.
  3. MVCC and transactions — XID assignment, snapshots, the proc array, CLOG, multixact, visibility rules. PostgreSQL's defining concurrency model.
  4. WAL and recovery — write-ahead logging, checkpoints, crash recovery, archive/restore, point-in-time recovery.
  5. Catalog — system catalogs (pg_class, pg_attribute, etc.), the bootstrap process, sys cache, relcache.
  6. Parser — bison grammar, parse analysis, the Query representation.
  7. Planner — path enumeration, cost estimation, plan generation, GEQO.
  8. Executor — pull-based plan node evaluation, expression interpreter, JIT, parallel query.
  9. Replication — streaming and logical replication, WAL senders/receivers, replication slots, publications/subscriptions.
  10. Postmaster and process model — the supervisor, fork dance, auxiliary processes, background workers.
  11. 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 --> Replication

Almost 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.

Systems – PostgreSQL wiki | Factory