Covering Indexes: INCLUDE Versus Adding Key Columns
Two ways to make an index answer a query without touching the table. They differ in ordering, index size, and what the engine can seek on.
3 min readPostgreSQL 18

A key column is carried at every level of the index tree; an included column exists only in the leaf. Both remove the same table lookup, so the choice between them looks cosmetic — and it decides how much every unrelated lookup pays.
What is the difference between INCLUDE and key columns?
Key columns are what the index is sorted by. They participate in seeking, ordering, and uniqueness, and they appear in every level of the B-tree, including the internal nodes that route a search.
Included columns — INCLUDE (…) in PostgreSQL 11 and later and in SQL Server —
are stored only in the leaf pages. They can be returned, but they cannot be
searched, they do not affect ordering, and they do not count toward the key.
-- Key columns: searchable, ordered, present at every tree level.CREATE INDEX orders_customer_status_total_idx ON orders (customer_id, status, total_amount);
-- Included column: payload only, leaf pages only.CREATE INDEX orders_customer_status_idx ON orders (customer_id, status) INCLUDE (total_amount);Both let SELECT total_amount FROM orders WHERE customer_id = ? AND status = ?
finish without touching the table — and which predicates the key can serve at all
follows from its column order. They are not
equivalent.
Why the difference matters
The first version sorts by total_amount within each (customer_id, status) pair.
That is useful if you ever filter or order by it — and dead weight if you do not.
Because it is a key column, it is carried in the internal nodes too, making the
tree wider and, past a point, deeper. A deeper tree costs an extra page read on
every single lookup, including the ones that never reference the column.
The second version keeps the tree narrow. The value is present exactly where it is needed, in the leaf, and nowhere else.
There is also a hard constraint, and the two engines draw it differently. SQL Server
does not count included columns toward its index key limits — 32 key columns and
1,700 bytes — so a wide output-only column that could never be a key can still be
carried. PostgreSQL counts INCLUDE columns toward its own 32-column limit, so the
exemption there is about tree navigation rather than about the limit.
The cost neither version avoids
Covering is not free in either form. The column is duplicated: it exists in the table and again in every index that includes it. Every update to that column now writes to both places, and in PostgreSQL an update that modifies any column referenced by an index disqualifies the row from the heap-only-tuple optimization, which has its own throughput cost.
The failure mode is an index that covers a wide SELECT — six or eight included
columns to satisfy one query — and turns into a second copy of the table with the
write amplification to match. Cover the columns the query actually returns, not the
ones it might.
Engine differences
PostgreSQL has supported INCLUDE on B-tree indexes since version 11. Covering
only pays off when the visibility map allows an index-only scan; without it the heap
fetch happens anyway and the extra columns bought nothing.
SQL Server treats included columns as the standard tool for eliminating key lookups back to the table, and its documentation recommends moving every non-searching column out of the key for exactly that reason.
InnoDB has no INCLUDE. Every column in a secondary index is a key column, and
every secondary index implicitly carries the primary key,
so an index on (customer_id, status) already covers a query that also selects
the primary key.
That implicit behavior is why covering in MySQL is often accidental.
Which columns belong in INCLUDE and which in the key?
If the column is filtered on, ordered by, or needs to be unique, it is a key
column. If it only appears in the SELECT list, it is an included column. If it is
neither, leave it out and accept the table lookup — an index that covers everything
is a table with extra steps.
Frequently asked questions
- What is the difference between INCLUDE and key columns in an index?
- Key columns are what the index is sorted by. They participate in seeking, ordering and uniqueness, and they appear at every level of the B-tree, including the internal nodes that route a search. Included columns are stored only in the leaf pages: they can be returned by a query but never searched, and they do not affect ordering. SQL Server also excludes them from its index key size limits; PostgreSQL still counts them toward its 32-column limit.
- Does MySQL support INCLUDE columns in an index?
- InnoDB has no INCLUDE. Every column in a secondary index is a key column, and every secondary index implicitly carries the primary key. An index on customer_id and status therefore already covers a query that also selects the primary key, which is why covering in MySQL is often accidental rather than designed. PostgreSQL added the INCLUDE clause in version 11; SQL Server has it as included or nonkey columns.
- Why doesn't my PostgreSQL covering index avoid reading the table?
- In PostgreSQL, covering only pays off when the visibility map allows an index-only scan. Without that the heap fetch happens anyway, and the included columns bought nothing while still costing index size and extra writes. Included columns live in the leaf pages, so they are available exactly when the query can be satisfied from the index alone.
- What is the write cost of a covering index?
- A covered column is duplicated: it exists in the table and again in every index that includes it, so every update to that column writes to both places. In PostgreSQL an update to any indexed column also disqualifies the row from the heap-only-tuple optimization, which carries its own throughput cost. An index covering six or eight columns becomes a second copy of the table with matching write amplification.
References
- docsMySQL 8.4 Reference Manual — Clustered and Secondary Indexes (opens in a new tab)
InnoDB has no INCLUDE; secondary indexes always carry the primary key.
- docsPostgreSQL 18 documentation — CREATE INDEX (opens in a new tab)
INCLUDE columns sit in leaf tuples, not in the upper-level entries used for tree navigation.
- release notesPostgreSQL 11 release notes (opens in a new tab)
The INCLUDE clause of CREATE INDEX was added in this release.
- docsPostgreSQL 18 documentation — Heap-Only Tuples (HOT) (opens in a new tab)
An update that modifies a column referenced by an index is not eligible for HOT.
-- written by
Elias RoweDatabase engineer
Elias Rowe writes about database engineering, SQL performance, and production systems. He focuses on measurable behavior, practical trade-offs, and conclusions that can be reproduced rather than assumed.


