PostgreSQL Enterprise (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is the Visibility Map and how does it enable Index-Only Scans?
senior LevelMost AskedpostgresqlAdvanced Internals
In Simple Words: Each table has an auxiliary Visibility Map (VM) bitmap:
- Each bit represents a heap page. A bit is set to
1if all tuples on that page are known to be visible to all current and future transactions (i.e. contains zero dead tuples). - Index-Only Scan: When traversing an index, PostgreSQL checks the Visibility Map:
- If the page bit is
1, PostgreSQL skips reading the table heap page entirely! - If
0, it must read the table page to verify MVCCxmin/xmaxvisibility.
- If the page bit is