|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 5:51 PM
Points: 1,627,
Visits: 2,827
|
|
I am seeing one of our drives are out of space.
And the tempdb is on that drive, it used about 20 gb space.
I go to management studio, and right click tempdb database, I see it inital size is 20 gb.
But if I see the spaced in the tempdb,
Data file is 20 gb, free space is 99%.
I tried to change the intial size to 10 gb, but when I reopen it, it changed back to 20 gb again.
What could be the problem?
Thanks
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 5:34 PM
Points: 11,784,
Visits: 28,041
|
|
size will not change until you stop and restart the server. at that time tempdb , since it will be recreated, will change to 10G instead of it's current size.
I don't think you can shrink tempdb while the server is running.
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 5:51 PM
Points: 1,627,
Visits: 2,827
|
|
But how it knows it will change to 10 gb?
I tried to change the size on then database property-file-inital size window, it not save it, when I reopen it, it changed to 20gb again.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 5:51 PM
Points: 1,627,
Visits: 2,827
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 2:09 PM
Points: 2,413,
Visits: 2,679
|
|
The following will change the initial size to 10,000MB. You will need to restart the SQL Server service for it to take effect.
ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 10000MB) GO You can validate the change by running:
SELECT name, size/128 as SizeMB from sys.master_files WHERE database_id = DB_ID('tempdb')
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 5:51 PM
Points: 1,627,
Visits: 2,827
|
|
Thanks.
Is there also a way to change in SSMS, like I said in earlier post it won't save it.
Thanks
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 12:04 AM
Points: 5,242,
Visits: 11,256
|
|
sqlfriends (3/2/2012) Thanks.
Is there also a way to change in SSMS, like I said in earlier post it won't save it.
Thanks you've been told twice already so, third time lucky you will need to restart the service for the change to take effect
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs"
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 5:51 PM
Points: 1,627,
Visits: 2,827
|
|
I understand after I restart the service, the changes will take effect if I use the SQL statement to change it. The thing I don't understand is by using ssms, will that work?
Also I just tried to do this on a tempdb on my local server on my workstation, I found from SSMS I can change the tempdb to a smaller size, and after I reopen it , it shows new size. I don't even need to restart the service, but why on the production server it cannot be changed?
Thanks
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 5:51 PM
Points: 1,627,
Visits: 2,827
|
|
Further experience on the production server, I found if I run the sql statement to change the file size, then I open ssms, it changed there, even I don't restart the service. I know it will take effect after restart.
But if I changed in production ssms , it won't save after I reopen it.
But on my local server, I can change it in SSMS, when reopen it, it saves the changes. The different behaviour on different computer confuse me.
Also if I change the restrict of file growth from unlimited to certain size, will that also take effect after tempdb restarted, I do see it saved on the produciton server after I change it in SSMS this time for this setting.
Thanks
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 5:34 PM
Points: 11,784,
Visits: 28,041
|
|
sqlfriends (3/2/2012) Further experience on the production server, I found if I run the sql statement to change the file size, then I open ssms, it changed there, even I don't restart the service. I know it will take effect after restart.
But if I changed in production ssms , it won't save after I reopen it.
But on my local server, I can change it in SSMS, when reopen it, it saves the changes. The different behaviour on different computer confuse me.
Also if I change the restrict of file growth from unlimited to certain size, will that also take effect after tempdb restarted, I do see it saved on the produciton server after I change it in SSMS this time for this setting.
Thanks
that behavior has to do with the size used. on your local, if you expand tempdb to something huge, then turn around and change the value again to a smaller value, it never actually filled that space...just reserved it, so there's no problem un-reserving that space.
on production, it actually grew to 20 gig because it needed it for whatever reason...once it was used, it remains at 20 gig until restart.
after changing it to 10 gig, it could very well be that later that afternoon, it will be 20 gig again, as it might expand due to needs.
so what you are seeing is you cannot immediately change the size reserved to be what is actually been used (even if it is 99% free...it's because ti was used by some process)
Lowell
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|