Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Doubts about dbcc shrinkfile working


Doubts about dbcc shrinkfile working

Author
Message
anoop.mig29
anoop.mig29
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 Visits: 155
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
raadee
raadee
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 Visits: 476
The 10 is the target size, so you would end up with a transaction log that is 10MB.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47388 Visits: 44399
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

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


anoop.mig29
anoop.mig29
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 Visits: 155
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
raadee
raadee
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 Visits: 476
You are correct.

Try it for yourself, create a test database and size the transactionlog to 100MB.
Then do the DBCC.
dan-572483
dan-572483
SSChasing Mays
SSChasing Mays (647 reputation)SSChasing Mays (647 reputation)SSChasing Mays (647 reputation)SSChasing Mays (647 reputation)SSChasing Mays (647 reputation)SSChasing Mays (647 reputation)SSChasing Mays (647 reputation)SSChasing Mays (647 reputation)

Group: General Forum Members
Points: 647 Visits: 1958
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."
Lynn Pettis
Lynn Pettis
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24263 Visits: 37984
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.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search