January 1, 2009 at 12:53 am
My database has MDF datafile 20G bytes, when I backup DB, the backup file = 20G also
After I delete many records, many backup tables in database, the backup file reduce to 10G. I use Shrink database, the LDF file reduces size, but MDF file is still big with 20G. The number of record in DB is reduced but MDF file is not reduced
So how to reduce it?
Thanks
January 1, 2009 at 1:00 am
Can you please run the maintenance plan to defrag if any tables are fragemented and then run the dbcc shrinkfile to reduce the size
January 1, 2009 at 1:29 am
You can use dbcc shrinkfile instead of dbcc shrinkdb. This enables you to select the file that you want to shrink and set the new size. The question is – why? Shrinking the file causes unwanted effects such as fragmentation. Also if the database reached this size there is a good chance that it will reach this size again, so why shrink it at all?
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
January 1, 2009 at 4:19 am
As I understand, we need to run SHRINKFILE twice
- First with "NOTRUNCATE" to reallocate spaces
- Second with "TRUNCATEONLY" to reduce size
Is it correct?
And how to calculate "target_size" value of SHRINKFILE?
Thanks
January 1, 2009 at 4:26 am
Normally you shouldn't shrink.
http://www.karaszi.com/SQLServer/info_dont_shrink.asp
If you have decided then decide the target size based on how much space you want to leave in mdf file after shrink operation is done. For example if your db is 10GB used up then leave 2-3GB for future expansion and set the target size to 12000.
MJ
January 1, 2009 at 4:39 am
MANU (1/1/2009)
Normally you shouldn't shrink.http://www.karaszi.com/SQLServer/info_dont_shrink.asp
If you have decided then decide the target size based on how much space you want to leave in mdf file after shrink operation is done. For example if your db is 10GB used up then leave 2-3GB for future expansion and set the target size to 12000.
MJ
Database is so big, there are many unused backup tables in database, so I delete them and reduce Database size to easy manage. That's why I want to shrink
As your article, after shrinking, the log file size will increase. Then can I continue to shrink Log file after that?
What the matter if I setup target size smaller, ex 8GB? Can it automatically to be 10G?
Thanks
January 1, 2009 at 5:02 am
Set target size to used space+Some breathing space. Yes, you can shring log file after that. Don't forget to do reindexing/defrag after shrink.
MJ
January 1, 2009 at 11:38 am
Database is so big, there are many unused backup tables in database, so I delete them and reduce Database size to easy manage. That's why I want to shrink
As your article, after shrinking, the log file size will increase. Then can I continue to shrink Log file after that?
What the matter if I setup target size smaller, ex 8GB? Can it automatically to be 10G?
Thanks
No - you don't want to shrink either the data file or the log file on a regular/scheduled basis. Do so will cause more problems than it is worth.
Please review the article I link to in my signature on how the manage transaction logs.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
January 1, 2009 at 11:48 am
I agree with Jeffrey, shrinking causes fragmentation on data files and is a waste of resources on log files. Set the files to be the amount of space you need for normal activity and leave them there. Monitor the data files to add space as data grows.
January 2, 2009 at 10:58 am
Jeffrey Williams (1/1/2009)
Database is so big, there are many unused backup tables in database, so I delete them and reduce Database size to easy manage. That's why I want to shrink
As your article, after shrinking, the log file size will increase. Then can I continue to shrink Log file after that?
What the matter if I setup target size smaller, ex 8GB? Can it automatically to be 10G?
Thanks
No - you don't want to shrink either the data file or the log file on a regular/scheduled basis. Do so will cause more problems than it is worth.
Please review the article I link to in my signature on how the manage transaction logs.
No, I don't shrink it regular. I just want to do once now to reduce MDF size because I just delete so many unused records in this DB
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply