IT lexicon › Database › Covering index

Covering index

Database På svenska → Updated: 2026-07-28

An index that contains all the columns a query needs, so the database can answer the query entirely from the index without looking up the actual table row (an "index-only scan"). A big performance win for read-heavy queries.

PostgreSQL: CREATE INDEX ON orders (customer_id) INCLUDE (total, status) — customer_id is searchable, total/status are included to avoid heap access. SQL Server has the same INCLUDE syntax. Mechanic: without covering, each hit must be followed by a lookup in the table (a heap fetch) → expensive I/O. With a covering index the index "covers" the query. Trade-off: a wider index = more disk + slower writes. In Postgres the visibility map must also be up to date (autovacuum) for an index-only scan to skip heap visits. A classic optimization for hot read paths.

← Back to the lexicon