Skip to main content

What Is a Spill to TempDB and Why Does It Occur?

Senior MS SQL
Quick Answer A spill to TempDB happens when SQL Server allocated less memory than a sort or hash operation actually needed. Overflow data is written to TempDB disk, which is orders of magnitude slower than memory. Caused by underestimated row counts (bad statistics). Look for sort warnings and hash warnings in execution plans.

Answer

A spill happens when the memory grant is too small and SQL Server must offload intermediate data to TempDB.

Common causes: inaccurate cardinality estimation, heavy sorts, hash joins, window functions.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice