An Index Only Scan Needs the Visibility Map to Skip the Heap
An index only scan answers a query entirely from the index, without visiting the table, which removes the random heap reads that usually dominate an index lookup. PostgreSQL can only do this when the index holds every column the query needs and the visibility map says the whole page is visible to all transactions, because the index entry alone cannot prove a row version is current. That makes it fragile in a useful way: a heavily updated table whose visibility map is stale falls back to heap fetches, and you will see it in the plan as a large Heap Fetches count.
Questions this Concept answers
Why can the index entry alone not establish that a row should be returned to your query?
J
jeremy
Video
Covering Indexes with INCLUDE for Index-Only Scans in PostgreSQL
A PostgreSQL index scan that finds qualifying rows must still make a second trip to the heap to retrieve any selected column the index does not carry — a heap fetch whose cost is invisible in the pla…