API performance Level 2 This level · 19 of 20
Medium sql database

What does INCLUDE do, and what makes an index covering?

INCLUDE adds non-key columns to the leaf level of a nonclustered index. They are not part of the search key, but their values can be read from the index. An index covers a query when it contains every referenced column as a key or non-key column, so the query can be answered without accessing the base table.

CREATE NONCLUSTERED INDEX IX_Address_PostalCode
ON Person.Address (PostalCode)
INCLUDE (AddressLine1, AddressLine2, City, StateProvinceID);
Sources (2)
  1. Microsoft Learn — create indexes with included columnslearn.microsoft.com
  2. Microsoft Learn — included columns and covering indexeslearn.microsoft.com
Previous
Next