Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Doubts about dbcc shrinkfile working Expand / Collapse
Author
Message
Posted Thursday, August 22, 2013 2:04 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 26, 2014 1:18 AM
Points: 90, Visits: 135
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
Post #1487099
Posted Thursday, August 22, 2013 2:49 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 1:43 AM
Points: 51, Visits: 414
The 10 is the target size, so you would end up with a transaction log that is 10MB.
Post #1487118
Posted Thursday, August 22, 2013 3:46 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:50 AM
Points: 39,977, Visits: 36,339
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 2008, MVP
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

Post #1487144
Posted Thursday, August 22, 2013 11:41 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, June 26, 2014 1:18 AM
Points: 90, Visits: 135
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
Post #1487641
Posted Friday, August 23, 2013 3:43 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 1:43 AM
Points: 51, Visits: 414
You are correct.

Try it for yourself, create a test database and size the transactionlog to 100MB.
Then do the DBCC.

Post #1487711
Posted Friday, August 23, 2013 11:39 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, September 26, 2014 3:00 PM
Points: 554, Visits: 1,621
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."

Post #1487960
Posted Friday, August 23, 2013 12:23 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 12:03 AM
Points: 20,703, Visits: 32,344
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.



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)
Post #1487974
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse