logoalt Hacker News

kbolino • today at 5:11 PM • 0 replies • view on HN

Index-only scans are possible when the index covers all involved columns and the query condition favors using the index. If you have an index on (col_a, col_b) but you run SELECT col_a WHERE col_b, you typically will not get an index-only scan because the query planner will decide against using the index in the first place, since it is ordered on col_a before col_b.