What is a covering index, and how does it help avoid an expensive lookup operation?
Short answer
A covering index includes all the columns a specific query needs, either as key columns or as included columns, meaning SQL Server can satisfy the entire query directly from the index itself without needing to go back to the actual table to retrieve additional column values…
Advertisement
AModel answer
A covering index includes all the columns a specific query needs, either as key columns or as included columns, meaning SQL Server can satisfy the entire query directly from the index itself without needing to go back to the actual table to retrieve additional column values, which is a common source of performance improvement.
CREATE NONCLUSTERED INDEX IX_Orders_Covering
ON Orders(CustomerId)
INCLUDE (OrderDate, Amount);Real-world example
A reporting query that filters by CustomerId and selects OrderDate and Amount runs significantly faster after a covering index is created that includes those exact columns, avoiding the need to look up additional data from the main table.
Likely follow-ups
- What is the difference between key columns and included columns in an index?
- How do you identify which queries would benefit from a covering index?
Related topics