[Quick Tip] When is TempDB Used?

[Quick Tip] When is TempDB Used?

[Quick Tip] When is TempDB Used?

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.

I have written another more comprehensive article in the past, dedicated to the TempDB system database in SQL Server. Feel free to check it out here.

Moreover, feel free to check out my eBook “Tuning SQL Server” where I dedicated a full chapter on the TempDB database.

 

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)

Loading...

Reference: SQLNetHub (https://www.sqlnethub.com)

© SQLNetHub

 

 

 


Recommended eBooks on SQL Server:

Developing with SQL Server: eBook by SQL Server MVP Artemakis Artemiou
Developing SQL Server: eBook by SQL Server MVP Artemakis Artemiou
Administering SQL Server: eBook by SQL Server MVP Artemakis Artemiou
Administering SQL Server: eBook by SQL Server MVP Artemakis Artemiou
Tuning SQL Server: eBook by SQL Server MVP Artemakis Artemiou
Tuning SQL Server: eBook by SQL Server MVP Artemakis Artemiou
Artemakis Artemiou
Artemakis Artemiou is a Senior SQL Server Architect, Author, Software Developer and a Microsoft Data Platform MVP. He has over 15 years of experience in the IT industry in various roles. Among other, via his initiative SQLEBooks.com, Artemakis authors and publishes eBooks on different topics on SQL Server. Artemakis currently serves as the President of the Cyprus .NET User Group (CDNUG) and the International .NET Association Country Leader for Cyprus (INETA). Additionally he is the founder of the SQLArtBits initiative that aims to provide the technical community with simple, yet powerful and high-quality SQL Server tools. Currently, the highlights of these tools are DBA Security Advisor and In-Memory OLTP Simulator. Artemakis's official website can be found at aartemiou.com. Artemakis's blogs can be found at: SQLNetHub.com and TechHowTos.com.