SQL Server › SQL Server Architecture & Editions

What is tempdb, and why is its configuration particularly important for overall SQL Server performance?

Intermediate

Answer

Tempdb is a special system database used by SQL Server for temporary objects like temporary tables, sorting operations, and row versioning, and since it is shared across the entire instance and heavily used by many different operations simultaneously, properly configuring it, such as using multiple equally sized data files, can significantly reduce contention and improve performance across your entire server.
-- Adding multiple tempdb files to reduce contention
ALTER DATABASE tempdb ADD FILE (
  NAME = tempdev2,
  FILENAME = 'C:\Data\tempdb2.mdf',
  SIZE = 512MB
);
Real-world example A database administrator configures tempdb with multiple equally sized data files matching the number of available processor cores, resolving a contention issue that had been causing intermittent slowdowns across the entire server.

Common follow-ups: How many tempdb files are generally recommended for a given server?;What kinds of operations put the heaviest load on tempdb?