What is running, what is in memory, and which file holds my table?
Before we follow a write, here is the whole machine: the processes, shared buffers, the WAL and the data files. Everything in later chapters happens somewhere on this picture.
Read each column top to bottom. A request enters at the process layer. Memory serves it when it can. Disk makes it permanent. When something is slow or broken, it lives in exactly one of these three layers. Name the layer first. That is the first diagnostic step.
The same layers as a still diagram, with every part named:
Request path
There is no hidden state. Every table, index, and log on this page is a file in one directory. One process owns it. You can inspect it with ls and du while the server runs. When disk fills in production, the failure is always a specific file class. It is never "the database" in the abstract. This tree tells you which file class in under a minute. Paths below are the common Linux defaults. The command under each tree asks the server for its own.
$ ls /var/lib/postgresql/18/main PG_VERSION # "18": which version owns this dir base/ # one subfolder per database global/ # cluster-wide tables + pg_control, # the file startup reads first pg_wal/ # THE WAL: 16 MB segment files: 000000010000000000000003 000000010000000000000004 pg_xact/ # which transactions committed pg_multixact/ pg_logical/ pg_stat/ postgresql.conf pg_hba.conf # (on Debian/Ubuntu the .conf files # live in /etc/postgresql/18/main/) $ ls base/16384/ # database oid 16384 16397 # ← table "users" is THIS file 16397_fsm 16397_vm # free-space + visibility maps 16405 # ← index "users_pkey": also a file
Every durability, replication, and recovery guarantee on this page reduces to one of five logs. For each log I give you the exact file name, where it sits, the mechanism, the failure mode when it is undersized, misplaced, or allowed to fill, and the command that shows its current state. Hold this pattern. A log's size divided by the write rate is a time window. Every operational budget on this page is one of those windows: recovery time, replica downtime tolerance, checkpoint headroom.
WAL recycling: when a segment can be reused
The other logs: MySQL · InnoDB: redo log and binary log · MongoDB · WiredTiger: journal and oplog · the pattern behind all five, and where they break
See the real thing: PostgreSQL 14 Internals by Egor Rogov, free PDF. The best single source on how Postgres actually works, and the book behind half the claims on this page.
How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.