SQL Server Interview Question #210

What is a spill to tempdb?

Advanced Query Optimization Senior Advanced

Detailed Explanation

A spill occurs when an operator such as Sort or Hash Match does not have enough granted memory to perform its work entirely in memory and writes intermediate data to tempdb.

Spills can increase I/O and query duration substantially, particularly with large datasets. Actual execution plans can expose spill warnings and runtime details.

The underlying cause may be inaccurate cardinality estimates, insufficient memory, excessive row width, poor query design, or an unsuitable plan. Simply increasing server memory is not always the correct solution.