SHARE
Facebook X Pinterest WhatsApp

How to Resize tempdb

Written By
thumbnail
Gregory Larsen
Gregory Larsen
Aug 2, 2018

When you are setting up a new SQL Server machine you need to determine how big you should make tempdb.  Not an easy task to get it right out of the box.  If you make tempdb too small, then the tempdb data or log file will have autogrowth events, as tempdb needs more space. Every time tempdb grows SQL Server will need to pause activity for a short period of time while the system grows the tempdb files.  This means your application transactions will have to wait while these autogrow events occur.  On the flip side if your tempdb database is oversized then you are just wasting disk space. 

To make sure you size tempdb appropriately you should monitor the tempdb space usage.  If there are autogrowth events occurring after you have recycled SQL Server than you might want to increase the size of your tempdb data files.  If tempdb never uses most of the tempdb space, then you might want to consider decreasing the size of tempdb. 

In order to resize tempdb you can use the ALTER DATABASE command.  By using the ALTER DATABASE command, you can set the initial size of the tempdb data and/or log files.  Below is an example where I changed the initial size of my tempdb DATA and LOG file:

ALTER DATABASE tempdb
  MODIFY FILE (Name=tempdb_data, filesize = 100MB),   
  MODIFY FILE (NAME=tempdb_log , filesize = 20MB);

Keep in mind the new sizes specified do not take effect until you recycle SQL Server.

See all articles by Greg Larsen

Recommended for you...

Best Online Courses to Learn SQL
Ronnie Payne
Sep 23, 2022
Best Courses for Database Administrators
Ronnie Payne
Jul 22, 2022
Tip 74 – Changing Cost Threshold for Parallelism
Gregory Larsen
Feb 24, 2021
How Many Databases Can You Name?
Brad Jones
May 11, 2020
Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.