Tracking All Visible Pages
In a multiversion engine, deciding whether a row is visible can require checking transaction status. To avoid this work, PostgreSQL keeps a visibility map, a small bitmap with bits per heap page. An all visible bit means every row on that page is visible to every transaction.
Why It Helps
- Vacuum can skip pages marked all visible, since they have no dead rows to clean.
- Index only scans can return data straight from the index when the referenced page is all visible, skipping the visibility check against the heap.
- The map is tiny, so it stays cached and is cheap to consult.
Keeping It Correct
When a page changes, its all visible bit is cleared, because new or updated rows might not yet be visible to all transactions. A later vacuum reexamines the page and may set the bit again once everything settles. A second frozen bit can also mark pages safe from transaction id wraparound.
Key idea
The visibility map flags pages whose rows are all visible to every transaction, letting vacuum skip clean pages and index only scans avoid heap visibility checks.