Problem Statement
What is the main benefit of a covering (included-columns) index for a SELECT?
Explanation
When all needed columns are in the index (keys + included), the plan can avoid extra lookups. This cuts I/O and latency for hot paths.
Use includes for non-key columns used in SELECT or WHERE to create index-only scans where supported.
Code Solution
SolutionRead Only
-- SQL Server style CREATE INDEX ix ON orders(customer_id) INCLUDE (status,total); -- Postgres: just place columns in index and rely on index-only scan when visible
Practice Sets
This question appears in the following practice sets:
