Sql-server – tempdb growth and shrinking tempdb

sql servertempdb

I’m a DBA that is fairly new to SQL Server coming over from a UNIX/Informix.

I have a question about tempdb growth:

From what I can see on regular databases if I start with a database that is 10 GB and then put in a bunch of data into it to make it 100 GB, and then delete 50 GB out of it I have to perform a shrink to reclaim space on the hard drive. Until I do that the space is allocated to the database

How does the tempdb work?

If an initial size is 10 GB and then some query grows tempdb to let’s say 100 GB and then terminates does the space become available for future tempdb queries/temp tables etc..?

Or does it release the space to the operating system?

Best Answer

Tempdb is recreated whenever the instance is restarted. At startup tempdb is created at the size specified in the system catalog. This means if you define tempdb to be 10GB, and it grows over time to 100GB, then you restart the server, tempdb will now be 10GB again.

The question about shrinking is one loaded with bad connotations. For a discussion around that, refer to this question.