<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.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>Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx</link><description>It is generally known that having a large number of virtual log files (VLFs) in a database transaction log is undesirable. A blog post by the Microsoft support team in Stockholm showed that a large number of virtual log files could seriously lengthen</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11794</link><pubDate>Mon, 09 Feb 2009 18:51:01 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11794</guid><dc:creator>Hitesh Jain</dc:creator><description>&lt;p&gt;Thank you, Linchi.&lt;/p&gt;
&lt;p&gt;Very informative post on troubleshooting TLogs issues.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11795</link><pubDate>Mon, 09 Feb 2009 18:57:18 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11795</guid><dc:creator>Chris Wood</dc:creator><description>&lt;p&gt;Linchi,&lt;/p&gt;
&lt;p&gt;What's the best way to see how many VLF's a transaction log file has in SQL2005 SP2?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11797</link><pubDate>Mon, 09 Feb 2009 19:54:38 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11797</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Chris:&lt;/p&gt;
&lt;p&gt;dbcc loginfo('database_name')&lt;/p&gt;
&lt;p&gt;... returns one row per VLF.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11798</link><pubDate>Mon, 09 Feb 2009 20:11:31 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11798</guid><dc:creator>Kevin Boles</dc:creator><description>&lt;p&gt;dbcc loginfo. &amp;nbsp;search web for details on it since it isn't in BOL.&lt;/p&gt;
&lt;p&gt;Linchi, I wonder if small transactions would see the same or similar reduction in throughput. &amp;nbsp;If you delete/insert/update 1-100 rows at a time in a loop (with begin/commit trans??) will there be a net reduction in executions per unit time with many VLFs?&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11799</link><pubDate>Mon, 09 Feb 2009 20:22:08 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11799</guid><dc:creator>Greg Linwood</dc:creator><description>&lt;p&gt;Its often important to pay attention to tempdb VLFs (rather than userdbs) as tempdb often does more TLogging than user dbs &amp;amp; is a central bottleneck, shared between dbs.&lt;/p&gt;
&lt;p&gt;Its very common for tempdb to be left to grow automagically but its a good practise to pre-set TLog size on tempdb to avoid excessive VLFs.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11805</link><pubDate>Mon, 09 Feb 2009 21:29:44 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11805</guid><dc:creator>Chris Wood</dc:creator><description>&lt;p&gt;That works great. Now when I see a number of rows coming back would this also indicate fragmentation of the database log? We have some servers database files on a SAN but currently most are on direct attached storage. From one of Linchi's previous blogs he had mentioned the potential performance issue with fragmented files. I would like to get some information from SQL server that can help me try an aleviate fragmentation and VLF's to improve performance.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11806</link><pubDate>Mon, 09 Feb 2009 21:44:18 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11806</guid><dc:creator>LeoPasta</dc:creator><description>&lt;p&gt;Hi Linchi,&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Great post. Some time ago, I wrote a procedure aiming at automating the process of reducing the number of VLF, I made it available at &lt;a rel="nofollow" target="_new" href="http://sqlblogcasts.com/blogs/leopasta/archive/2008/09/02/reducing-transaction-log-fragmentation.aspx"&gt;http://sqlblogcasts.com/blogs/leopasta/archive/2008/09/02/reducing-transaction-log-fragmentation.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;I have not used it extensively, so it may contain a few bugs, but during my internal tests on SQL 2008 it did the job.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11808</link><pubDate>Tue, 10 Feb 2009 01:02:01 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11808</guid><dc:creator>Kevin Boles</dc:creator><description>&lt;p&gt;Chris, you could have 2 forms of fragmentation problems. &amp;nbsp;First your OS files could be fragmented. &amp;nbsp;This is common when DBAs leave default settings for file size and growth. &amp;nbsp;It can have a significant affect on performance. &amp;nbsp;A windows file fragmentation checking tool is appropriate here.&lt;/p&gt;
&lt;p&gt;The data structures inside the sql server files can also become fragmented - in 2 ways. &amp;nbsp;Pages can be in a less-than-optimally-full state and pages can be out of order. &amp;nbsp;These too can lead to performance problems. &amp;nbsp;Much has been written and is available online and in BOL to diagnose and correct these issues.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11811</link><pubDate>Tue, 10 Feb 2009 05:32:25 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11811</guid><dc:creator>Linchi Shea</dc:creator><description>&lt;p&gt;&amp;gt; Linchi, I wonder if small transactions would see the same or similar reduction in throughput. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I'll cover that in the next post.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11815</link><pubDate>Tue, 10 Feb 2009 12:04:31 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11815</guid><dc:creator>Mike Walsh</dc:creator><description>&lt;p&gt;Great post. I have never taken the time to do a comparative analysis like this for this example. Now I'll have one more tool to use when showing people why it's best to &amp;quot;right size&amp;quot; a transaction log file instead of allow growths.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11825</link><pubDate>Tue, 10 Feb 2009 16:58:08 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11825</guid><dc:creator>ACALVETT</dc:creator><description>&lt;p&gt;Great post! Looking forward to part II&lt;/p&gt;
&lt;p&gt;Pulled the code below off a blog i wrote ages ago. Anyway, if you want to get the vlfs for all the databases on your server in one hit the code below works nicely.&lt;/p&gt;
&lt;p&gt;CREATE &amp;nbsp;TABLE #VLFS (fileid int,filesize bigint,startoffset bigint,fseqno bigint,status int,parity int,createlsn varchar(1000))&lt;/p&gt;
&lt;p&gt;CREATE TABLE #Results (SRV_Name nvarchar(500),Database_Name nvarchar(500),VLFS INT)&lt;/p&gt;
&lt;p&gt;exec master.dbo.sp_msforeachdb&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;@command1 = 'USE ? INSERT INTO #VLFS EXEC(''DBCC LOGINFO WITH TABLERESULTS'')',&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;@command2 = 'insert into #Results SELECT @@SERVERNAME,''?'',count(*) from #vlfs',&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;@command3 = 'truncate table #vlfs'&lt;/p&gt;
&lt;p&gt;SELECT * FROM #Results&lt;/p&gt;
&lt;p&gt;drop table #vlfs&lt;/p&gt;
&lt;p&gt;drop table #Results &lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11826</link><pubDate>Tue, 10 Feb 2009 17:54:21 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11826</guid><dc:creator>RangaSQL</dc:creator><description>&lt;p&gt;Very informative...Thanks Linchi.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11829</link><pubDate>Tue, 10 Feb 2009 22:14:44 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11829</guid><dc:creator>Glenn Berry</dc:creator><description>&lt;p&gt;Linchi,&lt;/p&gt;
&lt;p&gt;What kind of drive configuration do you have for the log file drive, i.e. how many spindles, what RAID level, etc.&lt;/p&gt;
&lt;p&gt;Is LOGWRITE the top wait type if you query sys.dm_os_wait_stats during the tests ?&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- Clear Wait Stats&lt;/p&gt;
&lt;p&gt;	DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR);&lt;/p&gt;
&lt;p&gt;	-- Isolate top waits for server instance &lt;/p&gt;
&lt;p&gt;	WITH Waits AS&lt;/p&gt;
&lt;p&gt;	(SELECT wait_type, wait_time_ms / 1000. AS wait_time_s,&lt;/p&gt;
&lt;p&gt;		100. * wait_time_ms / SUM(wait_time_ms) OVER() AS pct,&lt;/p&gt;
&lt;p&gt;		ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS rn&lt;/p&gt;
&lt;p&gt;	 FROM sys.dm_os_wait_stats&lt;/p&gt;
&lt;p&gt;	 WHERE wait_type NOT IN( 'SLEEP_TASK', 'BROKER_TASK_STOP', &lt;/p&gt;
&lt;p&gt;	 &amp;nbsp;'SQLTRACE_BUFFER_FLUSH', 'CLR_AUTO_EVENT', 'CLR_MANUAL_EVENT',&lt;/p&gt;
&lt;p&gt;	 &amp;nbsp;'LAZYWRITER_SLEEP')) -- filter out additional irrelevant waits&lt;/p&gt;
&lt;p&gt;	SELECT W1.wait_type, &lt;/p&gt;
&lt;p&gt;	 &amp;nbsp;CAST(W1.wait_time_s AS DECIMAL(12, 2)) AS wait_time_s,&lt;/p&gt;
&lt;p&gt;	 &amp;nbsp;CAST(W1.pct AS DECIMAL(12, 2)) AS pct,&lt;/p&gt;
&lt;p&gt;	 &amp;nbsp;CAST(SUM(W2.pct) AS DECIMAL(12, 2)) AS running_pct&lt;/p&gt;
&lt;p&gt;	FROM Waits AS W1&lt;/p&gt;
&lt;p&gt;	INNER JOIN Waits AS W2&lt;/p&gt;
&lt;p&gt;	ON W2.rn &amp;lt;= W1.rn&lt;/p&gt;
&lt;p&gt;	GROUP BY W1.rn, W1.wait_type, W1.wait_time_s, W1.pct&lt;/p&gt;
&lt;p&gt;	HAVING SUM(W2.pct) - W1.pct &amp;lt; 95; -- percentage threshold&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11831</link><pubDate>Tue, 10 Feb 2009 23:35:38 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11831</guid><dc:creator>Dave</dc:creator><description>&lt;p&gt;Awesome stuff, and much appreciated!&lt;/p&gt;
&lt;p&gt;Where did you get the 3m rows from? &amp;nbsp;Or did you use a custom routine to generate the data? &amp;nbsp;I would like to leverage the same data within our environment to show what type of performance degredation we are experiencing by performing your test against our own db log files with varying #'s of VLFs.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11832</link><pubDate>Wed, 11 Feb 2009 01:30:59 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11832</guid><dc:creator>Linchi Shea</dc:creator><description>&lt;p&gt;Glenn;&lt;/p&gt;
&lt;p&gt;Logwrite was the top wait type. There was nothing else going on else INSERT, UPDATE, and DELETE, and these were expected to be bottlenecked on log writes.&lt;/p&gt;
&lt;p&gt;To be honest, I didn't care about the the drive config because the only variable was the number of VLFs. But that could be a factor in determining the magnitude of the difference.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11833</link><pubDate>Wed, 11 Feb 2009 01:34:02 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11833</guid><dc:creator>Linchi Shea</dc:creator><description>&lt;p&gt;Dave;&lt;/p&gt;
&lt;p&gt;The three million rows were from a custom-written C# program that generates and loads TPC-C compliant data.&lt;/p&gt;
</description></item><item><title>Performance impact: a large number of virtual log files – Part II</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#11845</link><pubDate>Thu, 12 Feb 2009 05:46:42 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11845</guid><dc:creator>Linchi Shea</dc:creator><description>&lt;p&gt;In my previous post on the performance impact of having a large number of virtual log files (VLFs) in&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#12427</link><pubDate>Wed, 04 Mar 2009 17:24:03 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:12427</guid><dc:creator>Mario</dc:creator><description>&lt;p&gt;Linchi, great research work again. Do you also know why this is happening? In other words: which mechanism is responsible for the performance reduction?&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#17037</link><pubDate>Tue, 29 Sep 2009 06:29:17 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:17037</guid><dc:creator>altax</dc:creator><description>&lt;p&gt;That was a great piece of information. I was exactly searching this regarding virtual log files. Great research. I don't know hot to greet you. Very very thanks for the information. &lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#25435</link><pubDate>Sat, 22 May 2010 22:00:35 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:25435</guid><dc:creator>ra,as</dc:creator><description>&lt;p&gt;Could you tell me how i can create a database with a predefined set of VLF's?&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#29391</link><pubDate>Thu, 14 Oct 2010 16:07:46 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:29391</guid><dc:creator>Sean Peters</dc:creator><description>&lt;p&gt;Linchi, I may be late to the party here but I have one glaring question about your technique. &amp;nbsp;Did you reset the growth parameter on dbVLF_small to match dbVLF_large AFTER you created 20k vlfs but BEFORE you ran the queries? &amp;nbsp;My contention here is that the operations were impacted by the file growth operations themselves and not necessarily the sheer number of VLFs. &amp;nbsp;Although this doesn't explain the delete behavior.&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#29393</link><pubDate>Thu, 14 Oct 2010 16:19:01 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:29393</guid><dc:creator>Sean Peters</dc:creator><description>&lt;p&gt; . . . wait, actually it would explain the delete behavior. lol &amp;nbsp;So the question stands. &amp;nbsp;Did you make sure the growth parameters were the same before you ran the queries?&lt;/p&gt;
</description></item><item><title>Must-Have Resources - SQL Server Backup &amp; Recovery</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#40233</link><pubDate>Thu, 08 Dec 2011 20:40:48 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:40233</guid><dc:creator>Kevin Kline</dc:creator><description>&lt;p&gt;The industry's best resources for maximizing Microsoft SQL Server backup and recovery. Don't get burned!&lt;/p&gt;
</description></item><item><title>Follow-up Answers for my Australia Classes</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#42699</link><pubDate>Wed, 04 Apr 2012 22:56:36 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:42699</guid><dc:creator>Kalen Delaney</dc:creator><description>&lt;p&gt;I was out of the country for the last two weeks of March, delivering classes in Brisbane and Sydney,&lt;/p&gt;
</description></item><item><title>re: Performance impact: a large number of virtual log files – Part I</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2009/02/09/performance-impact-a-large-number-of-virtual-log-files-part-i.aspx#45321</link><pubDate>Mon, 24 Sep 2012 10:56:54 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:45321</guid><dc:creator>Mike Casey</dc:creator><description>&lt;p&gt;In reply to Sean, if you read the article's paragraph starting with 'the 20,000 virtual log files were generated as follows' you'll see that all the growth was done in a loop up front of the timed test, so file growth time can not be a factor... but there is no mention of running a disk defrag after the repeated growth, and it might be interesting to see how much of the time difference was down to more VLFs and how much was down to disk fragmentation.&lt;/p&gt;
</description></item></channel></rss>