As its names implies, the tempdb database contains temporary data that is created during SQL Server operations, therefore, the tempdb growth is one significant issue that needs to be properly managed in SQL Server.
Temporary data stored in tempdb system database
Temporary data stored in temdb may include: temporary user objects (i.e. temporary tables, cursors), row versions (i.e. those that come up from online index operations), and other internal objects that are created by SQL Server Database Engine.
The tempdb is global on a SQL Server Instance, that is available to all the users/databases on a SQL Server Instance, so in the cases where an instance might contain a large number of databases resulting to a large number of operations which use temporary data, this might have as an effect the tempdb size to increase rapidly.
How you can shrink tempdb?
So, how can you shrink the tempdb database and limit its size?
Even though tempdb is fully managed by SQL Server’s Database Engine, there are some things you can try to shrink it.
The following KB article describes three different methods for shrinking tempdb.
In summary, these are:
Altering the tempdb file size with the “ALTER DATABASE [tableName] MODIFY FILE” command
Using the “dbcc shrinkdatabase” command
Using the “dbcc shrinkfile” command
Note: Generally, it is not recommended to try and manually limit the size of tempdb. Instead, you need to make a proper disk capacity planning and know your databases and any heavy batch operations they may run that use tempdb.
- What are Exactly Orphaned Users in SQL Server?
- How to Patch a SQL Server Failover Cluster
- How to Add a Database to a SQL Server Availability Group Using T-SQL
- Top 10 SQL Server DBA Daily Tasks List
- The “Public” Database Role in SQL Server
- … all our SQL Server Administration Articles
Did you find this article useful and interesting? Feel free to leave your comment!
Subscribe to our newsletter and stay up to date with our latest articles on SQL Server and related technologies!
Check out our latest software releases! All our software tools have 30-day Trial Versions which are free to download.
Rate this article:
Reference: SQLNetHub.com (https://www.sqlnethub.com)
Artemakis Artemiou is a Senior SQL Server Architect, Author, and a 9 Times Microsoft Data Platform MVP (2009-2018). He has over 15 years of experience in the IT industry in various roles. Artemakis is the founder of SQLNetHub and TechHowTos.com. Artemakis is the creator of the well-known software tools Snippets Generator and DBA Security Advisor. Also, he is the author of many eBooks 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).