August 22, 2013 at 2:04 am
Hi friends i wanted to know about behaviour of dbcc shrinkfile command
dbcc shrinkfile(2,10)
now 2 denotes that i want to shrink log file
but what i wanted to know about is size to which it decrease.It know size is in 10 mb.
But what i wanted to know is whether size would reduce by 10 mb or reduce to 10 mb.
for eg suppose log file size is 100 mb.
then after executing above command would log file new size would be 10(100mb to 10mb) mb or 90 mb(100mb-10mb)
Thanks and Regards
Anoop
ps. I know shrinking is bad but still want to know about it
August 22, 2013 at 2:49 am
The 10 is the target size, so you would end up with a transaction log that is 10MB.
August 22, 2013 at 3:46 am
Having 10MB as the target number does not mean that the log will shrink to 10MB, only that 10MB is the minimum. If say the log has 25MB of log records in it, then it can't shrink to 10MB.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 22, 2013 at 11:41 pm
raadee (8/22/2013)
The 10 is the target size, so you would end up with a transaction log that is 10MB.
So u mean when i specify
dbcc shrinfile(2,10)
it tryies to reduce log file to size of 10MB (and not 90MB) provided there is data of size less then 10 MB in log file.
Am i right.please reply
Reagrds
Anoop
August 23, 2013 at 3:43 am
You are correct.
Try it for yourself, create a test database and size the transactionlog to 100MB.
Then do the DBCC.
August 23, 2013 at 11:39 am
Also, log files are written sequentially and will overwrite themselves only when the portion at the beginning of the file is no longer needed. When you shrink a log file, it will only truncate the portion at the end of that data is not needed. So you may not be able to shrink it to the target size even if much of the data is not needed, depending on where it's writing at the time. There's some good discussion of this topic on Books Online. Look up "Managing Log Files."
August 23, 2013 at 12:23 pm
Also, if your logfile grew to 100MB through normal operation you should leave it there. If you shrink it, SQL Server will just need to expand it again later when it needs more log space and can't reuse any of the VLFs in the logfile.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply