TempDB: SQL Server's Playground
TempDB is SQL Server’s laboratory. Temporary tables, sorts, worktables, spools, hash operations, and row versions used by snapshot isolation may all rely on it. If the database is the mind, TempDB is its workshop.
An overloaded TempDB slows down the whole system, like a workbench that is too small for the job.
⚙️ What goes into TempDB?
- Temporary tables (
#local,##global). - Table variables (
@table). - Sort and hash work for
ORDER BY,GROUP BY, and joins. - Row versions for snapshot isolation / RCSI when the version store is in TempDB.
- Work performed by
DBCC CHECKDB. - Spools, worktables, and workfiles.
🧠 TempDB architecture
TempDB is shared by the entire SQL Server instance and is recreated when the instance starts.