Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSQLcovering indexesSingle-choice MCQ

You have `CREATE INDEX idx ON t (a, b)` and run `SELECT b FROM t WHERE a = 5`. The plan shows `Index Scan` rather than `Index Only Scan`, even though both a and b are in the index. After a VACUUM the same query flips to `Index Only Scan`. What mechanism makes VACUUM the deciding factor?

CREATE INDEX idx ON t (a, b); SELECT b FROM t WHERE a = 5;