Cookbook recipe

Index-only scans and why the visibility map matters

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

You added a covering index but EXPLAIN still shows heap fetches. Index-only scans only stay "index-only" when the visibility map says pages are all-visible. Diagnose it Look for Heap Fetches in the plan: EXPLAIN (ANALYZE) SELECT…

Investigation Path

You added a covering index but EXPLAIN still shows heap fetches. Index-only scans only stay “index-only” when the visibility map says pages are all-visible.

Diagnose it

Look for Heap Fetches in the plan:

EXPLAIN (ANALYZE)
SELECT id FROM events WHERE id BETWEEN 1 AND 1000;
-- Index Only Scan ... Heap Fetches: 942

Many heap fetches mean the visibility map is stale because VACUUM has not marked those pages all-visible.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • Why it happens
  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes