Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSQLindex-only scansSingle-choice MCQ

Consider this on a freshly created index over an existing, never-modified table. EXPLAIN reports an Index Only Scan, but ANALYZE shows Heap Fetches equal to the row count on the FIRST run; a later run shows zero. The table genuinely never changed. What single event between the two runs eliminated the heap fetches?

-- table already VACUUMed once long ago, then this index was just built CREATE INDEX idx ON t (a) INCLUDE (b); EXPLAIN (ANALYZE, BUFFERS) SELECT a, b FROM t WHERE a = 42; -- Heap Fetches: N -- ... (no INSERT/UPDATE/DELETE happens) ... EXPLAIN (ANALYZE, BUFFERS) SELECT a, b FROM t WHERE a = 42; -- Heap Fetches: 0