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)