Discuss the concept of 'Index Scans' versus 'Index Seeks'.
Instruction: Explain the difference between index scans and seeks and their impact on query performance.
Updated
Official Answer
In SQL Server execution plans, an Index Seek uses index keys to locate qualifying key values or ranges. An Index Scan reads through an index's rows or pages to find results; execution may stop early when enough rows are produced. The operator name alone does not measure the work performed.
A seek can still read a large range, apply a residual predicate, or cause many lookups for missing columns. A scan can be a good choice when a query needs much of the data or the index covers a small result efficiently.
Inspect actual versus estimated row counts, rows read, logical reads, lookup work and elapsed time. Check predicate selectivity, key order, coverage, statistics and parameter sensitivity. Compare representative workloads before adding an index: indexes also consume storage and add write-maintenance cost.
A useful interview response explains why a particular access path fits the query. Replacing every scan with a seek is not a sound optimization objective.