Medium
SQL-O04sqlCovering Index For SELECT-Only Columns
Problem
Query: `SELECT email FROM users WHERE country = 'IN' AND city = 'Pune'`. The current index is `(country, city)`. Why is the planner still doing extra heap fetches, and what is a 'covering index'?
Input
Conceptual.
Output
Explanation + DDL
Constraints
—
Sample input
—
Sample output
After the index seek, the planner still hits the heap for `email`. A covering index includes `email` in the index payload (INCLUDE clause or trailing column).
Explanation
Indexes store keys; extra columns require a heap fetch. INCLUDE'd columns avoid that.
optimisationcovering-index@Microsoft
Visible test cases
in: explain
out: ok
Your solution — run it, use AI if stuck
sql
