A PostgreSQL query runs inside a server process, using pages that other processes can use too. Each stored row version is called a tuple. A query's answer depends on more than the bytes on those pages. Two readers can inspect the same cached page and return different prices, because their snapshots admit different row versions.
Follow the shop's blue mug, P7, from an application connection to its stored tuple. Then change its catalogue price from 20.00 to 22.00 and follow both readers back through the index. This gives query plans, buffer counts and vacuum a physical setting: which process does the work, where it finds a version, and what must remain after an update.
This is the independent price experiment from Storage and durability. Order 103 remains pending, with no payment; its agreed prices still total 29.00. Stock remains P3 10, P7 0 and P9 4. The drawings use invented page addresses, buffer contents and schedules, rather than tracing a running server.
Connections and backend processes
The application sends SQL over a connection. PostgreSQL's supervisor process accepts a new connection and starts a backend, the server process that handles that conversation. Subsequent commands and replies pass between the client and its backend.
The shop and a report can have separate connections and backends while using the same shared memory and database files. Their processes are separate; the stored pages need not be.
Figure 1One connection, one backend
Shop applicationConnection ASELECT price … P7
Report applicationConnection BA separate SQL conversation
↓ queries · ↑ rows, command results and errors
One PostgreSQL server instance
Supervisor process · accepts new connections, starts backends
Backend A · processParse/analyse → rewrite → plan → executeWork inside one backend
Backend B · processIts own query and transaction stateCan use the same cached pages
↓ shared access ↓
Shared memoryShared buffers · cached table and index pagesAlso shared coordination and WAL buffers
↓ page reads and later writes ↓
Server storageHeap files · index files · WAL
A process map for two direct server connections, with background processes added later. A pool may lend these connections to different requests. The supervisor is involved in establishing a connection; it does not forward each query between the client and its backend.
A connection, a transaction and a query are different things. One connection can carry many transactions over its lifetime. A transaction can contain several SQL commands. Without an explicit BEGIN, each ordinary standalone command still runs in a transaction of its own.
A connection pool lends existing connections to application requests. A backend may be idle while its client decides what to send, waiting for a lock or I/O, or executing a query. Having borrowed a connection does not mean useful query work is happening. Some plans also enlist parallel worker processes; those workers are extra participants, rather than a replacement for the client's backend.
Knowing which backend serves a request does not identify the cause of a slow response. Pool waiting can occur before the request reaches any backend. Operating and diagnosing PostgreSQL follows that request using evidence from the pool and server.
From SQL to an execution plan
The shop asks for one price:
SELECT priceFROM productsWHERE product_id = 'P7';
Inside the backend, parsing checks the syntax. Analysis resolves names such as products and price, their types and the operators to use. Rewriting transforms the query where needed, for example expanding a view into its underlying query.
The planner chooses a plan for producing the answer. It compares estimated work: scanning the products heap, or finding P7 through its primary-key index and fetching a tuple. The executor follows that chosen plan and returns the resulting price through the connection. These stages run inside the backend; they are not separate servers passing the request along.
The primary key supplies an index; it does not require an index scan. With only the three shop products, reading the tiny table can be cheaper. An index route is useful for explaining its mechanics, but it is not the plan this query must choose. Reading and repairing PostgreSQL plans tests the planner's choices against actual rows, buffers and repeated work.
Shared buffers
A backend needs a page in memory before it can read its tuples. PostgreSQL's shared buffers cache holds table and index pages for the server's backends. A page belongs to a particular table or index and has a block number within that stored object. A buffer slot is merely the place currently holding that page; the slot number is not the page's address.
The first query can bring in a page that the next backend reuses. The second backend then avoids fetching that page into shared buffers again. When another page needs room, replacement must choose a slot that can safely be reused.
One page serves two backends
Figure 2. Invented slots and page addresses; a buffer read may be served by the operating-system cache.Figure as text
A page read fills shared buffer slot 1. Backend B reuses it. Other pages fill the four slots. The clock skips pinned slot 2, reduces slot 3’s usage count, then replaces unpinned slot 4 at usage zero.
A shared-buffer hit found the page in this cache. A buffer miss needed a read into it. That read may come from the operating system's file cache, so a reported buffer read does not establish a physical drive read. The cache holds pages for indexes as well as heaps; an index lookup can need both.
Pins, content locks and replacement
A pin prevents a buffer from being repurposed while a backend uses its page. A short buffer content lock protects access to the page's contents. A backend can release the content lock after selecting a tuple while retaining its pin to use the tuple data. Neither mechanism is the transaction's row lock: they protect the shared page and its memory slot, rather than deciding which transaction may update P7.
Replacement uses a clock sweep, not a perfectly ordered list of last access times. A hand visits buffer slots. Pinned buffers cannot be reused; an unpinned buffer with a positive usage count gets its count reduced and another chance. An unpinned buffer at zero can supply a slot. Concurrent access can change pins and counts while the sweep proceeds, so there is no fixed sequence of victims to predict from access history alone.
A buffer holding a clean page can be reused without writing that page first. A dirty page’s changes must be written before its slot can safely hold another page. That can put write work on the path of a query trying to read. The write path below explains which processes can perform it.
Heap pages and row addresses
An ordinary PostgreSQL table is a heap: its tuples are not kept in primary-key order. Each heap page has a header, an array of line pointers, free space and tuple data. A line pointer records where a tuple's bytes lie within that page.
An index's heap locator is a TID, or tuple identifier: a block number and an item number. Suppose P7’s original tuple has the illustrative address (12,3). Read page 12 and use line pointer 3 to locate its bytes. The item number is not a byte offset.
Figure 3A row address stops at a line pointer
Index entry P7 → (12,3)
↓ page 12 · item 3
Page header · 24 bytes
Item 1 → P3Item 2 → P9Item 3 → P7 tuple bytes
Free space Line pointers grow down ↓ Tuple data grows up ↑
P7 · 20.00 tuple header + columns
P9 · 35.00
P3 · 4.50
Compaction can move tuple bytes within this page
Item 3 now stores their new byte offsetThe outside address stays (12,3)
A schematic 8 kB heap page, not to scale. Each line pointer uses 4 bytes. Page 12 and its item numbers are illustrative. Moving bytes within the page can preserve a TID; creating a new version by UPDATE gives that version a different TID.
The indirection lets PostgreSQL compact tuple bytes within a page without changing their outside address: it adjusts the line pointer's offset. It does not make that address a lasting product identity. PostgreSQL exposes the physical version's location as the system column ctid. An update creates a new version with another location, and a table rewrite can move versions too. Use product_id to identify P7.
This query reports whichever P7 version is visible to its snapshot. Its actual ctid comes from that table's current storage; it need not be the illustrative (12,3).
Large values and TOAST
A heap tuple cannot straddle pages, but a logical value can exceed one page. For supported variable-length types, TOAST can compress a large value or store it in chunks in an associated TOAST table. A small pointer then represents the out-of-line value in the main tuple.
Imagine a wide product description stored that way. Reading only price need not fetch and reconstruct the description; returning the description does. The exact representation depends on the type, storage policy and compressibility. Wide values that remain inline still reduce the number of tuples per page, so the displayed character count is a poor storage estimate.
Row versions and visibility
A snapshot describes which transaction effects an ordinary read admits when checking tuple versions; it does not copy the pages. Now change the price. A report first runs an ordinary query inside a read-only Repeatable Read transaction, establishing its snapshot. Another connection updates P7 and commits. The report then repeats its query; a later reader starts after the commit.
Two snapshots, one shared page
Figure 4. Ordinary reads in the independent price-update example. The report has already established its Repeatable Read snapshot.Figure as text
The report establishes an earlier snapshot. A writer creates and commits a £22 tuple beside the £20 tuple. The report still reads £20; a later snapshot reads £22.
The report still returns 20.00; the later snapshot returns 22.00. They are not reading private copies of the database. Each tests tuple metadata against its snapshot. Merely issuing BEGIN would not establish the report's ordinary Repeatable Read snapshot: the first snapshot-taking statement must have run. At Read Committed, a later statement instead takes a new ordinary snapshot.
What the tuple header tells the reader
A tuple carries a creator transaction identity, exposed as xmin, and information about its deletion or replacement, associated with xmax. An update marks the earlier version and creates another tuple. Transaction status tells whether that work committed or aborted; the snapshot tells whether that transaction's effects belong in this reader's view.
The report excludes the writer's new tuple even after the writer commits, because that transaction was not part of the committed history its snapshot admits. For the same reason, the replacement does not hide the old tuple from that report. The later snapshot admits the committed writer and therefore makes the opposite choice.
Transaction IDs alone are insufficient. A transaction with a lower ID can still have been in progress when the snapshot was established. Snapshot membership and commit outcome matter, not just comparing two numbers. A non-zero xmax does not by itself prove that a tuple is dead: it can reflect unfinished or aborted work, and row locking can use the field too. Header flags distinguish those cases.
If the writer rolls back, its new 22.00 tuple does not become an ordinary reader's value, and its attempted replacement does not remove 20.00. While the writer is uncommitted, other ordinary readers likewise cannot return its new price. This is why finding bytes that say 22.00 is insufficient evidence that a query should return 22.00.
These versions serve concurrency and can be removed when no longer needed. They are not a business price-history table, and they do not change the agreed 20.00 on order 103's mug line.
From an index entry to a visible row
A primary-key B-tree stores product keys with heap locators. Its branch pages guide the search to a leaf containing the matching key. The key can match while the referenced tuple is invisible to this snapshot, so an ordinary index scan still needs the heap visibility check.
For the lookup before the update, searching for P7 finds its leaf entry and heap locator. The backend follows that locator, tests the referenced version’s visibility and returns its price only when that version belongs in the query’s snapshot.
A key leads to a visible tuple
Figure 5. An illustrative index route, not the plan a tiny products table must use.Figure as text
The app asks for P7. The B-tree leaf supplies heap address (12,3), not the price. The reader checks that tuple against its snapshot and returns £20.
The index and heap are separate structures. The primary key does not turn the products heap into a table ordered by product_id. It supplies an access path whose entries can lead into any heap page. PostgreSQL index methods and operators develops the other access methods and the operators they can serve.
When an index-only scan can skip the heap
If a supporting index holds every value needed by the query, it can be eligible for an index-only scan. Our primary-key index alone lacks price, so it cannot answer this price query from its stored values.
Even with the values present, an index entry does not carry the heap tuple's full visibility information. PostgreSQL consults the heap page's all-visible bit in the visibility map. When set, it certifies that the page's tuples are visible to all relevant transactions, allowing the scan to avoid a heap visit. When clear, the scan must check the heap; a clear bit does not prove that a tuple is invisible.
Vacuum sets the proof when safe; changes to the heap page clear it. Updating another row on P7's page can therefore make an eligible index-only lookup visit the heap again. Covering a query and avoiding heap fetches are related conditions, rather than the same condition.
Heap-only tuple updates
The price changed, but the primary-key value P7 did not. PostgreSQL can sometimes keep the existing index entry and follow a link from the old tuple to the new one. This is a heap-only tuple, or HOT, update.
It needs space for the new version on the same page, and the update must not change columns referenced by the table's ordinary indexes. “Referenced” includes expression inputs, partial-index predicates and included columns, not just B-tree keys. Summarising indexes are an exception: PostgreSQL's BRIN can still need its summary updated without requiring a new per-tuple index entry.
An update can keep its index entry
Figure 6. Three independent physical layouts for the same price change. Addresses and cleanup timing are illustrative.Figure as text
With same-page room and no ordinary index referencing the changed price, the old index entry follows a HOT link to the new £22 tuple. After retention ends, cleanup can leave a redirect. A price index or full page instead requires new ordinary index entries.
In the HOT case, the index still targets (12,3). The old tuple links to (12,4), so heap access can follow the chain and select the version its snapshot needs. The new heap-only tuple has no independent entry in those indexes. The index target need not equal the ctid of the version eventually returned.
An index referencing price prevents that price update from being HOT. So does insufficient space on the old page, even if no indexed value changed. A non-HOT update needs new ordinary index entries for the new tuple, including a new P7 entry in the primary-key index. Old and new physical versions can temporarily have index entries for the same logical key; visibility and uniqueness enforcement account for the versions.
Free space and fillfactor
A table's fillfactor limits how full inserts try to make its pages, leaving space for later versions. Reserving more space can make same-page updates more likely, while needing more pages for the same initial rows. That trades scan and cache space for update opportunities.
It is not a HOT guarantee: the remaining space can run out, and an index-referenced change still fails the other condition. Changing the setting also does not immediately redistribute an already packed table. Choose it from the update workload rather than treating one percentage as universally right.
Reclaiming old versions
While the report still needs 20.00, cleanup must keep that tuple. Once it is no longer required, pruning can remove obsolete tuple bytes on the page. For a surviving HOT chain, the original line pointer can become a redirect to the oldest version still needed. The index keeps its original target while that redirect preserves the route.
Ordinary page access, including reads, can perform pruning when conditions permit; it is not exclusively a periodic vacuum job. Reusable bytes inside the page do not imply that the heap file became smaller. HOT also does not remove the need for vacuum's wider work. PostgreSQL vacuum and transaction age follows retained versions, transaction-age obligations and maintenance decisions.
The write path and background processes
The backend makes the update in a shared heap buffer. It also maintains any required index pages and generates write-ahead log records. Commit does not need every one of those pages written to its data file before the application hears success.
Commit establishes the transaction’s outcome. A later page write updates the data file, while cleanup reclaims versions no longer needed. Those events answer different questions and need not happen together.
Commit first. Page writing later.
Figure 7. Normal local durable commit settings and reliable storage; one possible schedule.Figure as text
The backend changes a shared page and generates WAL. Durable WAL permits commit acknowledgement. The heap file is written later. Later cleanup reclaims old tuple space and dirties the page again.
Before a changed data page reaches its file, WAL covering its changes must be durable: the write-ahead rule. With normal local durable commit settings, the required WAL through the commit record must also be flushed before acknowledging commit. The changed page may follow later, because restart can redo changes it lacks.
Several processes can move that work forwards. Their names describe different jobs:
Who performs the remaining work?
Process
Its part
Client backend
Executes SQL, changes buffers and generates WAL. Ensures its required commit flush; can also write a dirty victim buffer when it needs a slot.
WAL writer
Writes and flushes WAL in the background. It is especially relevant when a commit is allowed to acknowledge early.
Background writer
Writes selected dirty shared buffers so later allocation is more likely to find clean reusable slots.
Checkpointer
Writes the pages required to complete checkpoints, establishing progress from which restart recovery can begin.
Autovacuum workers
Carry out automatic vacuum and analyse work, including reclaiming dead-version space, maintaining visibility information and collecting planner statistics.
A committed version can be visible before its heap page reaches its file. A clean buffer can still hold old tuple versions. Free space can be reusable while the file retains its size. With asynchronous commit, even an acknowledged commit can precede its required durable WAL flush. None of those states proves the others.
PostgreSQL WAL, checkpoints and durability develops the native progress counters, settings and restart tests. The physical route here supplies their context: a backend chooses a visible tuple from shared pages, changes create more versions and index work, and separate writing and maintenance make that work durable and reusable.
Sources and further reading
The drawings are explanatory models for PostgreSQL 18, checked against its documentation and source. Their page addresses, transaction letters, buffer counts and event schedules are invented. They are not output from PostgreSQL or measurements of its timing.
The SQL was checked in PGlite 0.5.8 (PostgreSQL 18.3, WebAssembly). Separate checks on an owned disposable PostgreSQL 18.6 server confirmed the established-snapshot result, HOT tuple links and unchanged index targets, a post-cleanup redirect, and non-HOT counterexamples with a price index and insufficient same-page space. These checks do not turn the drawings into measured layouts or establish timing or crash behaviour.