Home All Groups Group Topic Archive Search About


Author
11 Dec 2008 9:59 PM
tulip
when you specify dbcc shrinkfile notruncate or dbcc shrinkfile truncateonly,
how do you know that the transaction log file would shrink to what size? we
had a rebuild index job run every weekend, after that, the t-log become 10G,
then we have bat file to do the shrink (now the t-log is only 138M), the
command is like this ( i got from the bat file), so how does the t-log know
what size to shrink to? we are not doing backup t-log. thanks

-- tell the file to reorganize (squeeze out the holes)
select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
shrinkfile('''+@logname+''',NOTRUNCATE) WITH NO_INFOMSGS'
execute( @cmd )

-- now we can truncate the file to remove the one big hole
select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
shrinkfile('''+@logname+''',TRUNCATEONLY) WITH NO_INFOMSGS'
execute( @cmd )

Author
12 Dec 2008 4:58 AM
FM
Hello,

Refer following link:
ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/e02b2318-bee9-4d84-a61f-2fddcf268c9f.htm

You can play with target_size.

Show quoteHide quote
"tulip" wrote:

> when you specify dbcc shrinkfile notruncate or dbcc shrinkfile truncateonly,
> how do you know that the transaction log file would shrink to what size? we
> had a rebuild index job run every weekend, after that, the t-log become 10G,
> then we have bat file to do the shrink (now the t-log is only 138M), the
> command is like this ( i got from the bat file), so how does the t-log know
> what size to shrink to? we are not doing backup t-log. thanks
>
> -- tell the file to reorganize (squeeze out the holes)
> select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
> shrinkfile('''+@logname+''',NOTRUNCATE) WITH NO_INFOMSGS'
> execute( @cmd )
>
> -- now we can truncate the file to remove the one big hole
> select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
> shrinkfile('''+@logname+''',TRUNCATEONLY) WITH NO_INFOMSGS'
> execute( @cmd )
>
Are all your drivers up to date? click for free checkup

Author
12 Dec 2008 5:25 PM
tulip
sorry, i tried the link but couldn't find the page.

Show quoteHide quote
"FM" wrote:

> Hello,
>
> Refer following link:
>
> ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/e02b2318-bee9-4d84-a61f-2fddcf268c9f.htm
>
> You can play with target_size.
>
> "tulip" wrote:
>
> > when you specify dbcc shrinkfile notruncate or dbcc shrinkfile truncateonly,
> > how do you know that the transaction log file would shrink to what size? we
> > had a rebuild index job run every weekend, after that, the t-log become 10G,
> > then we have bat file to do the shrink (now the t-log is only 138M), the
> > command is like this ( i got from the bat file), so how does the t-log know
> > what size to shrink to? we are not doing backup t-log. thanks
> >
> > -- tell the file to reorganize (squeeze out the holes)
> > select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
> > shrinkfile('''+@logname+''',NOTRUNCATE) WITH NO_INFOMSGS'
> > execute( @cmd )
> >
> > -- now we can truncate the file to remove the one big hole
> > select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
> > shrinkfile('''+@logname+''',TRUNCATEONLY) WITH NO_INFOMSGS'
> > execute( @cmd )
> >
Author
12 Dec 2008 6:48 AM
Aaron Bertrand [SQL Server MVP]
> had a rebuild index job run every weekend, after that, the t-log become 10G,
> then we have bat file to do the shrink (now the t-log is only 138M), the
> command is like this ( i got from the bat file), so how does the t-log know
> what size to shrink to? we are not doing backup t-log. thanks

Are you using simple recovery or full recovery?  If you are using full
recovery, why are you not backing up the transaction log?  If you don't care
about restoring to a point in time, then why not just use simple recovery?
You really shouldn't be shrinking the transaction log like this, what is the
point if it is going to balloon to 10GB again next weekend?  What did you
save except to make your index rebuild take longer as it will have to wait
for each autogrow event, because you are still going to need that space
available to accommodate the next index rebuild?  I strongly suggest you
read this in full, and if this is still the approach you want to take, read
it again:

http://www.karaszi.com/SQLServer/info_dont_shrink.asp
Author
12 Dec 2008 5:27 PM
tulip
we are using full recovery. We are doing log shipping, so every 15 mins we do
backup t-log. We have this db like 140g, then rebuild index over the weekend
create a t-log 50g. So if we do the backup t-log every 15 mins, shouldn't the
log file size shrink after that? thanks

Show quoteHide quote
"Aaron Bertrand [SQL Server MVP]" wrote:

> > had a rebuild index job run every weekend, after that, the t-log become 10G,
> > then we have bat file to do the shrink (now the t-log is only 138M), the
> > command is like this ( i got from the bat file), so how does the t-log know
> > what size to shrink to? we are not doing backup t-log. thanks
>
> Are you using simple recovery or full recovery?  If you are using full
> recovery, why are you not backing up the transaction log?  If you don't care
> about restoring to a point in time, then why not just use simple recovery?
> You really shouldn't be shrinking the transaction log like this, what is the
> point if it is going to balloon to 10GB again next weekend?  What did you
> save except to make your index rebuild take longer as it will have to wait
> for each autogrow event, because you are still going to need that space
> available to accommodate the next index rebuild?  I strongly suggest you
> read this in full, and if this is still the approach you want to take, read
> it again:
>
> http://www.karaszi.com/SQLServer/info_dont_shrink.asp
>
>
Author
13 Dec 2008 10:50 AM
Tibor Karaszi
BACKUP LOG doesn't shrink the file, it only empty the file. If your
rebuild job makes the file jump to 50GB, then there is little gain in
paying all the penalties to shrink the file if it will jump to 50GB
next week again. The key words here are "pay the penalty". If you
don't care about that, then shrink ahead... :-)
I suggest you read both below:

http://sqlblog.com/blogs/tibor_karaszi/archive/2007/02/25/leaking-roof-and-file-shrinking.aspx
http://www.karaszi.com/SQLServer/info_dont_shrink.asp


Show quoteHide quote
"tulip" <tu***@discussions.microsoft.com> wrote in message
news:E9CA91C6-63A3-4793-83EB-AA919FD4E687@microsoft.com...
> we are using full recovery. We are doing log shipping, so every 15
> mins we do
> backup t-log. We have this db like 140g, then rebuild index over the
> weekend
> create a t-log 50g. So if we do the backup t-log every 15 mins,
> shouldn't the
> log file size shrink after that? thanks
>
> "Aaron Bertrand [SQL Server MVP]" wrote:
>
>> > had a rebuild index job run every weekend, after that, the t-log
>> > become 10G,
>> > then we have bat file to do the shrink (now the t-log is only
>> > 138M), the
>> > command is like this ( i got from the bat file), so how does the
>> > t-log know
>> > what size to shrink to? we are not doing backup t-log. thanks
>>
>> Are you using simple recovery or full recovery?  If you are using
>> full
>> recovery, why are you not backing up the transaction log?  If you
>> don't care
>> about restoring to a point in time, then why not just use simple
>> recovery?
>> You really shouldn't be shrinking the transaction log like this,
>> what is the
>> point if it is going to balloon to 10GB again next weekend?  What
>> did you
>> save except to make your index rebuild take longer as it will have
>> to wait
>> for each autogrow event, because you are still going to need that
>> space
>> available to accommodate the next index rebuild?  I strongly
>> suggest you
>> read this in full, and if this is still the approach you want to
>> take, read
>> it again:
>>
>> http://www.karaszi.com/SQLServer/info_dont_shrink.asp
>>
>>
Author
12 Dec 2008 7:32 AM
David Portas
On 11 Dec, 21:59, tulip <tu***@discussions.microsoft.com> wrote:
Show quoteHide quote
> when you specify dbcc shrinkfile notruncate or dbcc shrinkfile truncateonly,
> how do you know that the transaction log file would shrink to what size? we
> had a rebuild index job run every weekend, after that, the t-log become 10G,
> then we have bat file to do the shrink (now the t-log is only 138M), the
> command is like this ( i got from the bat file), so how does the t-log know
> what size to shrink to? we are not doing backup t-log. thanks
>
> -- tell the file to reorganize (squeeze out the holes)
> select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
> shrinkfile('''+@logname+''',NOTRUNCATE) WITH NO_INFOMSGS'
> execute( @cmd )
>
> -- now we can truncate the file to remove the one big hole
> select @cmd = 'use [' + @dbname+']'+char(10)+'dbcc
> shrinkfile('''+@logname+''',TRUNCATEONLY) WITH NO_INFOMSGS'
> execute( @cmd )

Don't do this. It's better to determine the right size for the log and
then leave it alone. Regularly shrinking the log won't save you any
space at all. It just needlessly swallows a lot of resources and
downtime.

--
David Portas

Bookmark and Share