<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.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>Search results matching tag 'Inserts'</title><link>http://www2.sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Inserts&amp;orTags=0</link><description>Search results matching tag 'Inserts'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Halloween Protection – The Complete Series</title><link>http://www2.sqlblog.com/blogs/paul_white/archive/2013/02/20/halloween-protection-the-complete-series.aspx</link><pubDate>Wed, 20 Feb 2013 23:29:42 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47843</guid><dc:creator>Paul White</dc:creator><description>&lt;p align="left"&gt;&lt;a href="http://sqlblog.com/blogs/paul_white/image_10B79A4D.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;float:left;padding-top:0px;padding-left:0px;margin:0px 12px 0px 0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" align="left" src="http://sqlblog.com/blogs/paul_white/image_thumb_00C85589.png" width="240" height="86" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="left"&gt;&lt;font size="3" face="Calibri"&gt;I have just published a four-part series&lt;/font&gt;&lt;font size="3" face="Calibri"&gt; for &lt;/font&gt;&lt;a href="http://www.sqlperformance.com/" target="_blank"&gt;&lt;font size="3" face="Calibri"&gt;SQLPerformance.com&lt;/font&gt;&lt;/a&gt;&lt;font size="3" face="Calibri"&gt; on the Halloween Problem. Some of you will never have heard of this issue, and those that have might associate it only with T-SQL &lt;code&gt;UPDATE&lt;/code&gt; queries. In fact, the Halloween problem affects execution plans for &lt;code&gt;INSERT, UPDATE, DELETE&lt;/code&gt; and &lt;code&gt;MERGE&lt;/code&gt; statements.&lt;/font&gt;&lt;/p&gt;  &lt;p align="left"&gt;&lt;font size="3" face="Calibri"&gt;This is a topic I have been meaning to write about properly for years, ever since I read Craig Freedman’s 2008 &lt;a href="http://blogs.msdn.com/b/craigfr/archive/2008/02/27/halloween-protection.aspx" target="_blank"&gt;blog post&lt;/a&gt; on the topic, which ended with the cryptic comment:&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p align="left"&gt;&lt;font size="3" face="Calibri"&gt;&lt;em&gt;“…although I've used update statements for all of the examples in this post, some insert and delete statements also require Halloween protection, but I'll save that topic for a future post.”&lt;/em&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="left"&gt;&lt;font size="3" face="Calibri"&gt;That future post never materialized, sadly, so I thought I would have a go. &lt;/font&gt;&lt;font size="3" face="Calibri"&gt;The four parts of the series are summarized and linked below, I hope you find the material interesting.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;h3 align="left"&gt;&lt;a href="http://www.sqlperformance.com/2013/02/t-sql-queries/halloween-problem-part-1" target="_blank"&gt;&lt;font face="Calibri"&gt;Part 1 – The Halloween Problem and UPDATE statements&lt;/font&gt;&lt;/a&gt;&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;The SQL standard and three-phase separation&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Logical update processing&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Pipelined execution&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;The Halloween problem&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Avoiding the problem in UPDATE statements&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h3 align="left"&gt;&lt;a href="http://www.sqlperformance.com/2013/02/t-sql-queries/halloween-problem-part-2" target="_blank"&gt;&lt;font face="Calibri"&gt;Part 2 – The Halloween Problem in INSERT and DELETE queries&lt;/font&gt;&lt;/a&gt;&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;INSERT examples&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;DELETE examples&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Constraint checking and phase separation&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h3 align="left"&gt;&lt;a href="http://www.sqlperformance.com/2013/02/t-sql-queries/halloween-problem-part-3" target="_blank"&gt;&lt;font face="Calibri"&gt;Part 3 – Halloween Problem optimizations for MERGE&lt;/font&gt;&lt;/a&gt;&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;MERGE contains several optimizations the other DML statements do not&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Hole-filling with merge join&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Hole-filling with nested loops&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Avoiding an extra B-tree navigation&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Avoiding the join&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h3 align="left"&gt;&lt;a href="http://www.sqlperformance.com/2013/02/t-sql-queries/halloween-problem-part-4" target="_blank"&gt;&lt;font face="Calibri"&gt;Part 4 – The Halloween Problem and the Query Optimizer&lt;/font&gt;&lt;/a&gt;&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Early optimization approaches&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;The SQL Server optimizer approach&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;The case of the redundant sort&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;HP levels and properties&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Plan changes for Halloween Protection&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Non-spool options&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Row versioning&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;Heaps and forwarded records&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="left"&gt;&lt;font size="3" face="Calibri"&gt;T-SQL functions&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="left"&gt;&lt;font size="3" face="Calibri"&gt;As always, I appreciate your comments and feedback.&lt;/font&gt;&lt;/p&gt;  &lt;p align="left"&gt;&lt;font size="3" face="Calibri"&gt;Paul White      &lt;br /&gt;&lt;/font&gt;&lt;a href="http://twitter.com/SQL_Kiwi"&gt;&lt;font size="3" face="Calibri"&gt;@SQL_Kiwi&lt;/font&gt;&lt;/a&gt;&lt;font size="3" face="Calibri"&gt;      &lt;br /&gt;&lt;/font&gt;&lt;a href="mailto:SQLkiwi@gmail.com"&gt;&lt;font size="3" face="Calibri"&gt;SQLkiwi@gmail.com&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="left"&gt;&lt;a title="SQL Intersection" href="http://www.sqlintersection.com/" target="_blank"&gt;&lt;img title="Ill_Be_There4" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="Ill_Be_There4" src="http://sqlblog.com/blogs/paul_white/Ill_Be_There4_2D04DC6D.jpg" width="140" height="110" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>