When is TempDB Used? That’s a very good question!
TempDB is one of the system databases of SQL Server. As its name implies, it is being used for holding temporary stuff. However, after different discussions I had with a lot of people, I believe that many people have a misconception regarding when TempDB is actually used in SQL Server, and consequently, they might not be taking into full consideration the performance-related factors and guidelines about this special database.
So the question remains: When is TempDB Used?
TempDB is not just used for storing temporary tables. Besides from storing user objects (global/local temporary tables and indexes, temporary stored procedures, table variables, Tables returned in table-valued functions, or cursors), the TempDB database is also used for storing internal objects which are created by the Database Engine such as:
– Work tables that are used for storing intermmediate results.
– Work files for hash join or hash aggregate operations.
– Intermmediate sort results of operations such as index rebuild, etc.
Moreover, tempdb is used to store version stores, that is collection of data pages that contain data which is used by operations that utilize row versioning.
For all the above reasons, you need to take into consideration the performance optimization guidelines regarding the TempDB database, as it plays a significant role to the overall performance of your SQL Server instance.
Moreover, feel free to check out my eBook “Tuning SQL Server” where I dedicated a full chapter on the TempDB database.
Rate this article:
Reference: SQLNetHub (https://www.sqlnethub.com)