, ,

Every instance of SQL Server has a single TempDB system database which is shared by all other databases on the same instance. Since SQL Server 2005, TempDB has been used more and more with every new SQL Version.

TempDB is used for the following purpose:

  1. User Objects:
      1. Local and Global Temporary Tables and their indexes
      2. Table Variables
      3. Temp Procedures
  2. Internal Objects:
      1. Work tables for Hash operations and aggregates
      2. Work tables for DBCC CHECKDB and DBCC CHECKTABLE
      3. Work files needed for SORT, GROUP BY, ORDER BY, UNION operations
      4. CTEs: Common Table Expressions
      5. Storing Temporary LOB storage: If they won’t fit in Memory
      6. Work tables for processing Service Broker objects
  3. Version Store:
      1. Online Index Operations
      2. MARS- (Multiple Active Result Sets)
      3. Snapshot Isolation
      4. Read Committed Snapshot Isolation

Few important restrictions we have on TempDB:

  1. Cannot remove PRIMARY data file or log file
  2. Cannot rename or drop TempDB database
  3. Cannot make the TempDB OFFLINE
  4. Cannot add, remove or rename FILEGROUP
  5. Cannot change the Collation , default is Server Collation
  6. Cannot change the owner of the TempDB, its owner is always dbo.
  7. Cannot BACKUP or RESTORE TempDB

We would get into the details of TempDB and performance issues we face in Tempdb in future posts.


Subhro Saha