Explain the difference between an index scan and an index seek.
Last updated
An index seek navigates the B-Tree directly to the matching key or range, touching only qualifying rows. It is ideal for selective predicates like
WHERE id = 42.An index scan reads all or most leaf entries and then filters. It is chosen when many rows qualify, the predicate isn't SARGable (index-usable), or statistics favor it.
Selectivity decides which wins. An unexpected scan on a selective query usually signals a missing index or a function wrapped around the column.
- https://www.geeksforgeeks.org/sql/index-optimization/
- https://medium.com/@hnasr/index-seek-vs-index-scan-in-database-systems-641c2ac811fc
- https://medium.com/@tolgayildiz91/sql-server-index-seek-vs-index-scan-real-benchmark-with-1-million-rows-includes-execution-plans-9cabd261a543
- https://dev.to/devmatsu/how-relational-databases-find-database-understanding-table-and-index-scans-49d9
- https://learn.microsoft.com/en-us/sql/relational-databases/showplan-logical-and-physical-operators-reference?view=sql-server-ver17
- https://dev.to/rhuturaj_takle/query-optimization-589d
- https://learn.microsoft.com/en-us/sql/t-sql/statements/set-showplan-all-transact-sql?view=sql-server-ver17
- https://dev.to/mashrulhaque/how-to-read-sql-server-execution-plans-7-things-that-matter-3pnm