Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Shinking Tempdb

Author  Topic 

rsn1966
Starting Member

9 Posts

Posted - 2010-09-24 : 15:10:57
I am running SQL Server 2008 Enterprise Edition (64-bit). I noticed that my hard disk space is getting low so I checked the size of the databases on my server. The largest database that I have is about 70 Gb. When I checked the system databases, I noticed that tempdb is 360 Gb. I attempted to shrink the size of tempdb using Microsoft SQL Server Management Studio but it didn't work. Can anyone recommend a method to shrink the file size of tempdb.mdf?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-24 : 15:15:11
You should never shrink tempdb as it could cause data corruption. To resize tempdb, restart your SQL Server service to set it back down to its initial size. Make sure the initial size is appropriate though so that it does not need to grow back out.

The fact that you've got a tempdb of that size indicates a problem. Sizing tempdb is a complex topic, but this will get you started: http://msdn.microsoft.com/en-us/library/ms345368.aspx

Do you have a maintenance plan in place to rebuild indexes? If so, then that's likely a problem as the maintenance plan does not do a good job of it. It doesn't explain 360GB though if your largest database is 70GB.

Do you have inefficient code? Do you make heavy use of temp tables?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

rsn1966
Starting Member

9 Posts

Posted - 2010-09-24 : 15:28:32
I did have a maintenance plan which rebuilds indexes. I will remove that maintenance plan. As for usage, the database has several large tables. The database users view the data through custom views that have been setup. All data tables are read only and will not allow users to write to any table.

I will try to restart SQL Server to see if that works.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-24 : 15:35:47
I wouldn't remove the maintenance plan unless you plan on using something in its place. My point about the rebuild indexes task of a maintenance plan is that it does not do a good job at selecting which indexes to reindex and what options to use. Due to this, many people have written custom scripts to handle the task. Here is mine in case you are interested: http://weblogs.sqlteam.com/tarad/archive/2009/11/03/DefragmentingRebuilding-Indexes-in-SQL-Server-2005-and-2008Again.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

rsn1966
Starting Member

9 Posts

Posted - 2010-09-24 : 15:49:28
After restarting SQL Server, the file size of Tempdb.mdf has not gone down. As of a few weeks ago, Tempdb.mdf was not as large as it is today. As for queries, many of the users run queries using the custom views that I have setup. Is it possible that the custom views that could be the issue that is causing the growth of the Tempdb.mdf?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-24 : 16:09:23
You need to check the initial size of tempdb then. Right click on it and go to properties. Perhaps someone else has set the size very, very high.

I've got a 6TB database, and we had at one point about a 350GB tempdb. It's typically in the neighborhood of 32GB though.

Anything's possible as to the cause.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-09-25 : 03:39:52
We see a number of questions here where a restart of SQL Service does not set TEMPDB back to it configure initial size. I don't know what the cause is.

You could manually start SQL Service in SINGLE USER MODE, and then shrink TEMPDB. Be very careful to follow the instructions on Microsoft website carefully. There must be no other activity that is accessing other databases when TEMPDB is shrunk - otherwise corruption of those databases is possible.

Question: Can one just rename the TEMPDB files when SQL Service is stopped so that SQL Server creates new ones on start up? (and if not just rename the files back again)
Go to Top of Page
   

- Advertisement -