Published on

June 16, 2007

Improvements in TempDB in SQL Server 2005

SQL Server 2005 introduced several important improvements in the TempDB, which is a system database used for temporary storage and processing of data. These enhancements significantly enhanced the performance and efficiency of TempDB, resulting in improved overall performance of SQL Server.

Reduced Input/Output Traffic

One of the key improvements in TempDB in SQL Server 2005 is the reduction in Input/Output (I/O) traffic. This was achieved by improving the logging mechanism. In SQL Server 2005, TempDB does not log the “after value” for every operation. For example, for an INSERT operation, the after value is not logged in the transaction log as it is already logged in the TempTable. Similarly, for a DELETE operation, the after value is not logged as it does not exist. This optimization significantly improves the performance of TempDB.

Improved File System

In addition to the logging improvements, SQL Server 2005 also introduced enhancements in the file system of the operating system. These improvements, although not directly related to SQL concepts, further contribute to the overall performance of TempDB.

Reduced Latch Contention

SQL Server 2005 addressed the issue of UP latch contention in TempDB. Each file in TempDB is now filled up in proportion to the free spaces it contains. This reduces the latch contention in TempDB when multiple users are accessing it simultaneously, resulting in improved performance.

Worktable Caching and Memory Management

Worktable caching and memory management were also improved in SQL Server 2005. All temporary objects, such as table variables and local tables, are now cached in the TempDB system catalog if they are smaller than 8 MB. This caching mechanism reduces the workload on TempDB when these objects are created again. For larger objects, such as temporary tables, SQL Server 2005 introduced background differed drop. This means that when a large object is dropped in TempDB, a background process takes care of the drop operation, allowing the main process to continue without waiting. This significantly improves application performance.

Usage of TempDB

TempDB is used by various features and functionalities in SQL Server 2005, including query triggers, snapshot isolation, MARS (Multiple Active Result Sets), online index creation, temporary tables, table variables, table-valued functions, DBCC CHECK, LOB (Large Object) parameters, cursors, Service Broker and event notification, XML and LOB variables, query notifications, database mail, index creation, and user-defined functions.

Best Practices and Recommendations

When working with TempDB in SQL Server 2005, it is important to follow some best practices and recommendations:

  • Analyze the existing workload and adjust the space for projected concurrent activities in TempDB.
  • Perform index maintenance and update statistics on TempDB, even though objects in TempDB are not permanent.
  • Set Auto Grow to ON for TempDB. Instant file initialization improves the performance of auto grow operations in TempDB.
  • Create TempDB on a separate disk drive than other databases. This can improve performance as different disk controllers can enhance disk input/output.

By following these best practices and recommendations, you can optimize the usage of TempDB and ensure optimal performance of your SQL Server 2005 environment.

References:

MS TechNet – Working with tempdb in SQL Server 2005

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.