Type & function library
SQL-callable functions for every built-in data type
src/backend/utils/adt
System caches — src/backend/utils/cache
System caches
src/…/cache
Text stemmers — src/backend/snowball
Text stemmers
src/backend/snowball
Application
Any program that opens
a database connection
Client tools
psql, pg_dump and friends, all speaking libpq
src/bin
Interactive psql — src/bin/psql
Interactive
psql
src/bin/psql
Dump & restore — src/bin/pg_dump
Dump & restore
src/bin/pg_dump
Generators & docs
Perl scripts that synthesise headers and the SGML
manual
src/tools
DBA or developer
Types SQL and runs
maintenance tools
Extensions
Contrib modules loaded into the backend as shared
libraries
contrib
Remote tables — contrib/postgres_fdw
Remote tables
contrib/postgres_fdw
Crypto functions — contrib/pgcrypto
Crypto
functions
contrib/pgcrypto
Internal C API
Headers and macros every backend file and extension
compiles against
src/include
fmgr ABI — src/include/fmgr.h
fmgr ABI
src/include/fmgr.h
Node types — src/include/nodes
Node types
src/include/nodes
libpq client library
Builds the frontend/backend protocol and returns
result sets
src/interfaces
Send & fetch — src/interfaces/libpq/fe-exec.c
Send & fetch
src/…/fe-exec.c
Query buffers — src/interfaces/libpq/pqexpbuffer.c
Query buffers
src/…/pqexpbuffer.c
Procedural languages
Handlers that run PL/pgSQL, Perl, Python and Tcl
bodies
src/pl
Query engine
Parses, plans and executes each statement for one
session
src/backend
Parse & plan — src/backend/optimizer/plan
Parse &
plan
src/…/plan
DDL commands — src/backend/commands
DDL
commands
…/commands
Report errors — src/backend/utils/error
Report
errors
src/…/error
Foreign PostgreSQL
Another server queried as foreign tables
Heap, WAL & buffers
The cluster on disk, read through a shared buffer
pool
src/backend/storage
Buffer cache — src/backend/storage/buffer
Buffer cache
src/…/buffer
Access methods — src/backend/access
Access methods
src/backend/access
Regression suite
pg_regress plus the SQL and TAP tests it drives
src/test
SQL regress — src/test/regress/sql
SQL regress
src/test/regress/sql
TAP driver — src/test/regress
TAP driver
src/test/regress
PG_GETARG / PG_RETURN macros
PQconnectdb, PQexec
PQexec, PQgetvalue, PQclear
runs generate-wait_event_types.…
runs psql / pg_dump
ereport, errmsg,
fmgr calls
GetConnection, libpq to…
wire protocol on port 5432
SPI_execute back into SQL
calls type & operator functions
loads shared library
on CREATE…
foreach, lfirst, list_length
calls the language handler
table_open, buffer reads/writes
tuples and index entries
pg_regress feeds scripts to psql
PQenterPipelineMode tests
ONE PROCESS PER CLIENT
CLIENT SIDE
Programs linked with libpq on a user's own
host
src/common and src/port are compiled into both the client tools
and the backend; they are not a separate process.
FORKED PER CONNECTION
POSTGRES BACKEND
The postgres server process and its shared buffers
Autovacuum, WAL senders and other background workers share this code but are not drawn.
SOURCE TREE ONLY
BUILD & TEST
Perl and SQL harnesses run from the checkout
NOT THIS INSTANCE
OTHER SERVERS
Foreign PostgreSQL databases reached over
the wire
System map
How PostgreSQL runs
›
Whole system
›
Expand all
About
Key
Operation
State / resource
→
Labelled direction
→
Main path
More links
┄┄
Return path
┄
Inferred (dashed)
∘⋯
Starts a process (dotted)
Opens a map
100%
Scroll or pinch to zoom · drag to pan