Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum Rss Feed

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Rss Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles

Database User and Programming Tips

Posted August 2, 2018

How to Resize tempdb

By Greg Larsen

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:

  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

Database User and Programming Tips Archives