|
sql
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dbcc shrinkfile
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 ) 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 ) > 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 ) > > > had a rebuild index job run every weekend, after that, the t-log become 10G, Are you using simple recovery or full recovery? If you are using full> 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 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 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 > > 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 quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi "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 >> >> On 11 Dec, 21:59, tulip <tu***@discussions.microsoft.com> wrote:
Show quoteHide quote > when you specify dbcc shrinkfile notruncate or dbcc shrinkfile truncateonly, Don't do this. It's better to determine the right size for the log and> 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 ) 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
Other interesting topics
SQL 2005: "Function argument count error." error
listing sql server and instances Collation Issue Access 2000 or 2003 project - can it connect to sql server 2008? performance question - high cpu usage Active/Active/Active Cluster question SQL 2000 and 2005 On Save Box Oracle Linked Server 16GB memory for SQL Creating a job |
|||||||||||||||||||||||