<?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>Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx</link><description>In the previous blog I had listed all bulk import optimizations. Now, I will describe each of these optimizations in detail in separate blog entries. Let me first start with minimal logging. By the way minimal logging is also called bulk-logging but the</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#7472158</link><pubDate>Tue, 05 Feb 2008 21:59:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7472158</guid><dc:creator>Alex Rosa</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Interisting post.&lt;/p&gt;
&lt;p&gt;I've been trying to reproduce it with the script below, but with no success when I change the recovery model.&lt;/p&gt;
&lt;p&gt;USE AdventureWorks;&lt;/p&gt;
&lt;p&gt;CREATE TABLE t_heap (c1 INT, c2 INT, c3 DECIMAL (38,2), c4 CHAR(1000));&lt;/p&gt;
&lt;p&gt;-- HERE OK, I got the same result.&lt;/p&gt;
&lt;p&gt;BULK INSERT t_heap &lt;/p&gt;
&lt;p&gt;FROM 'C:\t_heap.dat' WITH (TABLOCK, FIELDTERMINATOR ='|') &lt;/p&gt;
&lt;p&gt;------------------------------------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;-- HERE OK, I got the same result.&lt;/p&gt;
&lt;p&gt;ALTER DATABASE AdventureWorks SET RECOVERY FULL&lt;/p&gt;
&lt;p&gt;DECLARE @I INT&lt;/p&gt;
&lt;p&gt;SELECT @I = 0&lt;/p&gt;
&lt;p&gt;WHILE (@I &amp;lt; 5) &lt;/p&gt;
&lt;p&gt;BEGIN&lt;/p&gt;
&lt;p&gt;	INSERT INTO T_HEAP WITH (TABLOCK) VALUES &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;(@I, @I + 5000, 10.2, REPLICATE ('A', 60))&lt;/p&gt;
&lt;p&gt;	SET @I = @I + 1&lt;/p&gt;
&lt;p&gt;END&lt;/p&gt;
&lt;p&gt;SELECT TOP 5 operation,context,[log record length]&lt;/p&gt;
&lt;p&gt;FROM fn_dblog(null, null) &lt;/p&gt;
&lt;p&gt;WHERE allocunitname='dbo.t_heap' &lt;/p&gt;
&lt;p&gt;ORDER BY [Log Record Length] DESC&lt;/p&gt;
&lt;p&gt;Simple/Bulk recovery model I'm getting this result:&lt;/p&gt;
&lt;p&gt;LOP_INSERT_ROWS	LCX_HEAP	1116&lt;/p&gt;
&lt;p&gt;------------------------------------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;ALTER DATABASE AdventureWorks SET RECOVERY SIMPLE&lt;/p&gt;
&lt;p&gt;-- repeat INSERT and SELECT above&lt;/p&gt;
&lt;p&gt;------------------------------------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;ALTER DATABASE AdventureWorks SET RECOVERY BULK_LOGGED&lt;/p&gt;
&lt;p&gt;-- repeat INSERT and SELECT above&lt;/p&gt;
&lt;p&gt;My setup:&lt;/p&gt;
&lt;p&gt;Microsoft SQL Server 2005 - 9.00.3200.00 (Intel X86) &lt;/p&gt;
&lt;p&gt;	Oct &amp;nbsp;2 2007 11:33:27 &lt;/p&gt;
&lt;p&gt;	Copyright (c) 1988-2005 Microsoft Corporation&lt;/p&gt;
&lt;p&gt;	Developer Edition on Windows NT 6.0 (Build 6000: )&lt;/p&gt;
&lt;p&gt;If I got it right, the log record length result with SIMPLE/BULK recovery model should be 92 instead of 1116, right?&lt;/p&gt;
</description></item><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#7472529</link><pubDate>Tue, 05 Feb 2008 22:21:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7472529</guid><dc:creator>Sunil Agarwal</dc:creator><description>&lt;p&gt;You don't get minimal logging with regular TSQL INSERT statement independent of the recovery model. However, we are looking into if we can remove this restriction for regular inserts in future releases including SQL2008&lt;/p&gt;
</description></item><item><title>&lt;h1&gt;SQL Shorts&lt;/h1&gt;</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#7476757</link><pubDate>Wed, 06 Feb 2008 01:03:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7476757</guid><dc:creator>SELECT IsUseless(blabber) from sys.innarwebs CROSS APPLY jmass(blog)</dc:creator><description>&lt;p&gt;The big news of the week is Windows Server 2008 RTM'ing. Read more here. The storage engine team has begin a series on bulk insert. It is definitely recommended reading. Part 1, Part 2, Part 3. The S ...&lt;/p&gt;
</description></item><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#7527401</link><pubDate>Fri, 08 Feb 2008 01:13:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7527401</guid><dc:creator>Alex Rosa</dc:creator><description>&lt;p&gt;Thanks for the answer.&lt;/p&gt;
&lt;p&gt;I was looking for an article talking about the differences among FULL, SIMPLE and RECOVERY model (which each one of this setting really write in the log file), but I haven't find it.&lt;/p&gt;
&lt;p&gt;Could you talk about this or blog about it?&lt;/p&gt;
</description></item><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#7528348</link><pubDate>Fri, 08 Feb 2008 01:56:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7528348</guid><dc:creator>Sunil Agarwal</dc:creator><description>&lt;p&gt;BOL has a good description on different recovery model. If you think something is not well covered, please send me a mail and we will update the BOL. In a nutshell, under SIMPLE recovery model, SQL Server truncates the inactive portion of the log but otherwise the logging is similar to what we have under bilk-logging recovery model.&lt;/p&gt;
</description></item><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#7843272</link><pubDate>Fri, 22 Feb 2008 03:36:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7843272</guid><dc:creator>jl999</dc:creator><description>&lt;p&gt;If you have a table with clustered index, and with existing data, say you have 30 million in the table. When you bulk import 10 million more, each one would be fully logged, correct? &lt;/p&gt;
&lt;p&gt;What's the best way to achieve minimal logging in this scenario, drop the clustered index first, then add the clustered index back after bulk import? For a large table, creating a clustered index might take a while. But is it still a better option than having a clustered index in place when importing?&lt;/p&gt;
</description></item><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#7843331</link><pubDate>Fri, 22 Feb 2008 03:46:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7843331</guid><dc:creator>Sunil Agarwal</dc:creator><description>&lt;p&gt;I recommend reading the following white paper that dealt with exactly these kinds of questions. This is still applicable for SQL2005. I will follow up this thread with some changes we have made for minimal logging in SQL Server 2008.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/incbulkload.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/incbulkload.mspx&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#9934757</link><pubDate>Wed, 09 Dec 2009 19:22:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9934757</guid><dc:creator>navneet.sqldba</dc:creator><description>&lt;p&gt;Hello Vishal&lt;/p&gt;
&lt;p&gt;It is a very good article.&lt;/p&gt;
&lt;p&gt;Can You Elabrate on the Below.I have picked the lines from your article.&lt;/p&gt;
&lt;p&gt;&amp;quot;This is because during the transaction log backup, the state of the pages involved in the bulk import may have changed between the time bulk import was done and the transaction log back is initiated. &amp;quot;&lt;/p&gt;
</description></item><item><title>re: Bulk Import Optimizations (Minimal Logging)</title><link>http://blogs.msdn.com/sqlserverstorageengine/archive/2008/02/05/bulk-logging-optimizations-minimal-logging.aspx#9936814</link><pubDate>Mon, 14 Dec 2009 23:37:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9936814</guid><dc:creator>Sunil Agarwal</dc:creator><description>&lt;p&gt;The pages containing the minimally logged operations are backed up as part of log backup. When these log records are restored as part of restore, we don't have the UNDO information in case the changes in &amp;nbsp;these pages need to be undone.&lt;/p&gt;
</description></item></channel></rss>