Skip to main content

What Is TempDB Contention and What Causes It?

Senior MS SQL
Quick Answer TempDB contention typically hits PFS, GAM, and SGAM pages รขโ‚ฌโ€ special allocation pages that every new temp object allocation touches. In high-concurrency workloads, many sessions compete for the same pages. Fix: add multiple TempDB data files (one per CPU core up to 8), enable trace flag 1118, use SQL Server 2016+ with automatic improvement.

Answer

TempDB contention occurs when multiple threads compete for the same allocation pages (PFS, GAM, SGAM) or metadata structures.

Typical causes include:

  • Too few TempDB data files
  • Heavy use of temp tables/table variables
  • Large sorting or hashing operations
  • High row versioning pressure

Fixes: increase file count, equal-size files, optimize workload, reduce spills.

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