<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Shrinking the Transaction Log files in SQL Server</title><link>http://blogs.msdn.com/b/suhde/archive/2009/03/16/shrinking-the-transaction-log-files-in-sql-server.aspx</link><description>Hi Friends! 
 This blog post is mainly to address concerns about increasing log file space, and how to go about to shrink the file. I am adding a priliminary content here as of now, but I will update this content as and when I get time and new content</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Shrinking the Transaction Log files in SQL Server</title><link>http://blogs.msdn.com/b/suhde/archive/2009/03/16/shrinking-the-transaction-log-files-in-sql-server.aspx#9883736</link><pubDate>Tue, 25 Aug 2009 17:33:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9883736</guid><dc:creator>Suhas De</dc:creator><description>&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;Thanks for the comments.&lt;/p&gt;
&lt;p&gt;Shrinking a Transaction Log file generally does not need any resources and is very quick (generally does not take more than a few seconds). Please check DBCC LOGINFO(DatabaseName) to know how much of the log can be shrunk.&lt;/p&gt;
&lt;p&gt;Also, DBCC SHRINKFILE can be blocked by other users / applications trying to access the database. Make sure that there are no users or applications connected to the database before executing the command.&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Suhas&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9883736" width="1" height="1"&gt;</description></item><item><title>Resources required to shrink the log file</title><link>http://blogs.msdn.com/b/suhde/archive/2009/03/16/shrinking-the-transaction-log-files-in-sql-server.aspx#9882990</link><pubDate>Tue, 25 Aug 2009 00:47:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9882990</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Thanks for a great write up on the log; we have a very large logfile (14GB or so), for a 40Gb database. And per above ( sqlperf) it's less than 1% utilized! So, I can't wait to shrink it; but, I'm a little afraid; how many database resources does shrinking use? Is it quick, or intensive? Should I do it after hours? Will it take seconds, or minutes, or hours?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9882990" width="1" height="1"&gt;</description></item><item><title>re: Shrinking the Transaction Log files in SQL Server</title><link>http://blogs.msdn.com/b/suhde/archive/2009/03/16/shrinking-the-transaction-log-files-in-sql-server.aspx#9836522</link><pubDate>Fri, 17 Jul 2009 07:01:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9836522</guid><dc:creator>Suhas De</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;Thanks a lot for your comments. Really appreciate it.&lt;/p&gt;
&lt;p&gt;To answer your first question, VLFs have been introduced to reduce the overall cost of finding the next free block. If we make the VLFs small enough to be able to accommodate just one Log Record (or eradicate the concept of VLF all together), we will have to examine each log record to check if it is free and can be over-written. This will increase the overall cost of finding the next free record.&lt;/p&gt;
&lt;p&gt;Consider the following scenario:&lt;/p&gt;
&lt;p&gt;My log file is small and can hold 10 records. I have the following:&lt;/p&gt;
&lt;p&gt;Record 1	=&amp;gt; Tran 1 (Start)&lt;/p&gt;
&lt;p&gt;Record 2	=&amp;gt; Tran 1 (Insert)&lt;/p&gt;
&lt;p&gt;Record 3	=&amp;gt; Tran 2 (Start)&lt;/p&gt;
&lt;p&gt;Record 4	=&amp;gt; Tran 1 (Insert)&lt;/p&gt;
&lt;p&gt;Record 5	=&amp;gt; Tran 2 (Delete)&lt;/p&gt;
&lt;p&gt;Record 6	=&amp;gt; Tran 2 (Delete)&lt;/p&gt;
&lt;p&gt;Record 7	=&amp;gt; Tran 1(Update)&lt;/p&gt;
&lt;p&gt;Record 8	=&amp;gt; Tran 2 (Commit)&lt;/p&gt;
&lt;p&gt;Now, when I start Tran 3, Record 9 will be utilized [Record 9 =&amp;gt; Tran 3 (Start)] and the next record (say, insert for Tran 3) will have to go to Record 10 [Record 10 =&amp;gt; Tran 3 (Insert)]. &amp;nbsp;Where will the next record go? To find that out, we have to scan the Log File from the beginning to find the next free record. As you can understand, each time I hit the end of the file, I have to start scanning from the beginning. It’s easy when the log file is small, but when the log file is huge, this can create severe performance issues.&lt;/p&gt;
&lt;p&gt;Grouping the records into logical segments (VLFs) can reduce the overall cost of finding the next free block. The larger the logical segment, the less number of scans we have to do, and hence the lower the cost. However, at the same time, the larger the size of the segment, the more space we waste. So, we have to strike a balance between the cost and space wasted. Hence, we came up with the concept of VLFs.&lt;/p&gt;
&lt;p&gt;Your second question is a bit tricky and will need a lengthy explanation. If it’s ok for you, I will prefer writing a whole blog post on this topic. I will have some time during this week-end, so, by Monday, you should find a detailed post on this.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Suhas.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9836522" width="1" height="1"&gt;</description></item><item><title>re: Shrinking the Transaction Log files in SQL Server</title><link>http://blogs.msdn.com/b/suhde/archive/2009/03/16/shrinking-the-transaction-log-files-in-sql-server.aspx#9836090</link><pubDate>Thu, 16 Jul 2009 23:55:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9836090</guid><dc:creator>David</dc:creator><description>&lt;p&gt;&amp;quot;So as to be able to properly utilize log space, a log file is divided into logical segments called VLFs or Virtual Log Files&amp;quot;&lt;/p&gt;
&lt;p&gt;A question from someone who is not really qualified to ask it...&lt;/p&gt;
&lt;p&gt;Could you explain why VLFs are beneficial? &amp;nbsp;Why not allow the logical log to rotate through the whole physical log with a pointer to the next free space, rather than divide the physical log into large chunks? &amp;nbsp;Log backup would record the last LSN backed up, and you could use that and the active log pointers to figure out what is &amp;quot;inactive&amp;quot; and can be reused for new log records. &lt;/p&gt;
&lt;p&gt;Also, I have read in the documentation (Transaction Log Physical Architecture) that truncation of the log marks any VLFs as inactive &amp;quot;whose [log] records all appear in front of the ... MinLSN&amp;quot;. &amp;nbsp;Shouldn't that continue on and say &amp;quot;or after the last-written log record&amp;quot;? &amp;nbsp;Or does &amp;quot;in front of&amp;quot; include the tail-end VLFs? &amp;nbsp;Please excuse me, I am having a hard time &amp;quot;wrapping my mind around&amp;quot; the logical log.&lt;/p&gt;
&lt;p&gt;Why doesn't an helpful post like this receive more comments? &amp;nbsp;I have not seen any more helpful description of shrinking a transaction log. &amp;nbsp;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9836090" width="1" height="1"&gt;</description></item><item><title>Anith &amp;raquo; Shrinking the Transaction Log files in SQL Server</title><link>http://blogs.msdn.com/b/suhde/archive/2009/03/16/shrinking-the-transaction-log-files-in-sql-server.aspx#9481729</link><pubDate>Mon, 16 Mar 2009 20:20:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9481729</guid><dc:creator>Anith &amp;raquo; Shrinking the Transaction Log files in SQL Server</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.anith.com/?p=19333"&gt;http://www.anith.com/?p=19333&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9481729" width="1" height="1"&gt;</description></item></channel></rss>