Covering Indexes and Index-Only Scans

Identify when a leaf entry has every requested value and when row visibility still requires another access.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. A covered query can read values directly from an index
  2. Visibility is a separate obligation for versioned engines

A covered query can read values directly from an index

An ordered index on customer key with an included status field can sometimes answer a query filtering by key and returning status. It need not fetch a full record merely to obtain that field when index entries already carry it. Larger leaf payloads increase index size, may reduce locality and add maintenance on writes. Include only data justified by important access patterns.

Visibility is a separate obligation for versioned engines

A query must still return versions visible to its snapshot. Some engines can skip table visits only when metadata certifies visibility, while otherwise checking the row or version store. An index being covering for values is therefore not alone a guarantee about actual I/O. B-tree page layout explains physical access, and snapshot isolation explains version eligibility.[1][2]

References

  1. PostgreSQL Global Development Group, PostgreSQL Documentation ↩
  2. CMU 15-445/645, Introduction to Database Systems: Lectures ↩