<?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>Nested Loops Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx</link><description>SQL Server supports three physical join operators: nested loops join, merge join, and hash join. In this post, I’ll describe nested loops join (or NL join for short). The basic algorithm In its simplest form, a nested loops join compares each row from</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Nested Loops Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#693728</link><pubDate>Thu, 10 Aug 2006 00:47:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:693728</guid><dc:creator>bartd</dc:creator><description>Great info, Craig -- I don't think I've seen this common operator dissected so thoroughly anywhere else. &amp;nbsp;Thanks! </description></item><item><title>re: Nested Loops Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#699235</link><pubDate>Mon, 14 Aug 2006 11:26:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:699235</guid><dc:creator>robineast</dc:creator><description>The section 'What about full outer joins' was fascinating. Can you expand on what that query plan is showing. I presume the Concatenation operator implements the Union with lines 2-4 being the first query and lines 5-9 being the second query. What's the Compute Scalar for? and the TOP(Expression)?&lt;br&gt;&lt;br&gt;Also you mention in the note about the query plan using a clustered index scan instead of a seek. There are 2 clustered index scans in the plan and I presume you mean the first one - it wouldn't make sense to have an index seek for the outer table (or set) of an NL join.</description></item><item><title>re: Nested Loops Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#700308</link><pubDate>Tue, 15 Aug 2006 02:18:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:700308</guid><dc:creator>craigfr</dc:creator><description>Your analysis is correct. &amp;nbsp;The concatenation is the union, the red lines (2-4) are the left outer join, and the green lines (5-9) are the semi-join to complete the full outer join.&lt;br&gt;&lt;br&gt;Compute scalar simply computes an expression. &amp;nbsp;In this case it computes NULL constants for the customer columns. &amp;nbsp;This is needed since semi-joins do not produce output values for the inner table (the customer table in this case). &amp;nbsp;Recall that the semi-join is just checking for existence; it does not actually match any particular row.&lt;br&gt;&lt;br&gt;The top is an unnecessary optimization to stop the table scan from producing more than one row. &amp;nbsp;Again, the semi-join is just checking for existence so a single match is all that we need. &amp;nbsp;I say &amp;quot;unnecessary&amp;quot; because the semi-join would stop after a single match even without the top.&lt;br&gt;&lt;br&gt;You are also correct, that the clustered index scan that I referenced is the inner one. &amp;nbsp;Sorry for the ambiguity.</description></item><item><title>Joins Dissected on CraigFr's blog</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#702908</link><pubDate>Wed, 16 Aug 2006 22:29:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:702908</guid><dc:creator>Bart Duncan's SQL Weblog</dc:creator><description>CraigFr has a great series of posts in his blog describing the difference between the various logical...</description></item><item><title>Merge Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#703336</link><pubDate>Thu, 17 Aug 2006 06:15:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:703336</guid><dc:creator>Craig Freedman's WebLog</dc:creator><description>In this post, I’ll describe the second physical join operator: merge join (MJ).&amp;amp;amp;nbsp; Unlike the nested...</description></item><item><title>Database Programming: Everything You Always Wanted To Know About JOIN Semantics, But Were Afraid To Ask</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#751284</link><pubDate>Wed, 13 Sep 2006 02:34:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:751284</guid><dc:creator>Ward Pond's SQL Server blog</dc:creator><description>Every once in awhile, I get an opportunity to look around for new and interesting things to read.&amp;amp;amp;nbsp;...</description></item><item><title>Deadlock Troubleshooting, Part 3</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#770931</link><pubDate>Mon, 25 Sep 2006 21:39:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:770931</guid><dc:creator>Bart Duncan's SQL Weblog</dc:creator><description>Here’s an example of the classic scenario that is usually used to introduce the concept of a deadlock:...</description></item><item><title>Deadlock Troubleshooting, Part 3</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#945352</link><pubDate>Fri, 03 Nov 2006 22:25:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:945352</guid><dc:creator>Bart Duncan's SQL Weblog</dc:creator><description>&lt;p&gt;Here’s an example of the classic scenario that is usually used to introduce the concept of a deadlock&lt;/p&gt;
</description></item><item><title>Parallel Nested Loops Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#1042560</link><pubDate>Thu, 09 Nov 2006 06:26:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1042560</guid><dc:creator>Craig Freedman's WebLog</dc:creator><description>&lt;p&gt;SQL Server parallelizes a nested loops join by distributing the outer rows (i.e., the rows from the first&lt;/p&gt;
</description></item><item><title>Query Plans and Read Committed Isolation Level</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#2379022</link><pubDate>Wed, 02 May 2007 22:08:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2379022</guid><dc:creator>Craig Freedman's WebLog</dc:creator><description>&lt;p&gt;Last week I looked at how concurrent updates may cause a scan running at read committed isolation level&lt;/p&gt;
</description></item><item><title>re: Nested Loops Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#3290961</link><pubDate>Thu, 14 Jun 2007 17:45:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3290961</guid><dc:creator>Gustavo Ayala</dc:creator><description>&lt;p&gt;I don't understand how SQL estimates row count for the output of inner loop joins.&lt;/p&gt;
&lt;p&gt;For example I have a query where I got 7 estimated row count I'm joining with a high selectivity secondary index ( actually the index is not clustered but it's unique ).&lt;/p&gt;
&lt;p&gt;In the execution plan then I got 7 estimatod row count before the join , 1 estimated row count from the index and the output is 14 estimated row count !!&lt;/p&gt;
&lt;p&gt;How come the estimated row count gets doubled if I'm joining with 4 columns ( wich have an unique index and I see the index is used in the execution plan )&lt;/p&gt;
&lt;p&gt;Since I've got a lot of joins the problem escalates until the estimated row count gets too high and unrealistic.&lt;/p&gt;
</description></item><item><title>re: Nested Loops Join</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#3676361</link><pubDate>Wed, 04 Jul 2007 00:12:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3676361</guid><dc:creator>craigfr</dc:creator><description>&lt;p&gt;I'm not sure I understand your question. &amp;nbsp;I would suggest posting your question if possible along with an example repro and query plan to the SQL Server Database Engine forum at: &lt;a rel="nofollow" target="_new" href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=93&amp;amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=93&amp;amp;SiteID=1&lt;/a&gt;.&lt;/p&gt;
</description></item><item><title>Join a SQL Server "joins type" - for Newbie</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#4277340</link><pubDate>Tue, 07 Aug 2007 17:38:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4277340</guid><dc:creator>SQL Server Transact-SQL (SSQA.net)</dc:creator><description>&lt;p&gt;Since the beginning of learning SQL Server I'm pretty much confused with JOIN conditions that defines&lt;/p&gt;
</description></item><item><title>SQL in the Wild  &amp;raquo; Blog Archive   &amp;raquo; Execution plan operations - joins</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#6909327</link><pubDate>Sun, 30 Dec 2007 22:59:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6909327</guid><dc:creator>SQL in the Wild  » Blog Archive   » Execution plan operations - joins</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://sqlinthewild.co.za/index.php/2007/12/30/execution-plan-operations-joins/"&gt;http://sqlinthewild.co.za/index.php/2007/12/30/execution-plan-operations-joins/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Ranking Functions: RANK, DENSE_RANK, and NTILE</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#8346528</link><pubDate>Tue, 01 Apr 2008 00:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8346528</guid><dc:creator>Craig Freedman's SQL Server Blog</dc:creator><description>&lt;p&gt;In my previous post , I discussed the ROW_NUMBER ranking function which was introduced in SQL Server&lt;/p&gt;
</description></item><item><title>Conversion and Arithmetic Errors</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#8436319</link><pubDate>Tue, 29 Apr 2008 02:44:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8436319</guid><dc:creator>Craig Freedman's SQL Server Blog</dc:creator><description>&lt;p&gt;Let's take a look at a simple query: CREATE TABLE T1 (A INT, B CHAR(8)) INSERT T1 VALUES (0, '0') INSERT&lt;/p&gt;
</description></item><item><title>Random Prefetching</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#8987912</link><pubDate>Wed, 08 Oct 2008 00:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8987912</guid><dc:creator>Craig Freedman's SQL Server Blog</dc:creator><description>&lt;p&gt;In my last post , I explained the importance of asynchronous I/O and described how SQL Server uses sequential&lt;/p&gt;
</description></item><item><title>What is the difference between sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats?</title><link>http://blogs.msdn.com/craigfr/archive/2006/07/26/679319.aspx#9025351</link><pubDate>Fri, 31 Oct 2008 00:53:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9025351</guid><dc:creator>Craig Freedman's SQL Server Blog</dc:creator><description>&lt;p&gt;SQL Server includes two DMVs - sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats - that&lt;/p&gt;
</description></item></channel></rss>