{"id":1471,"date":"2012-12-21T10:00:02","date_gmt":"2012-12-21T15:00:02","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=1471"},"modified":"2014-11-13T13:50:34","modified_gmt":"2014-11-13T18:50:34","slug":"a-join-a-day-the-nested-loops-join","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/","title":{"rendered":"A Join A Day \u2013 The Nested Loops Join"},"content":{"rendered":"<div>\n<h3>Introduction<\/h3>\n<p>\nThis is the twenty-first post in my <a href=\"http:\/\/sqlity.net\/en\/1146\/a-join-a-day-introduction\/\">A Join A Day<\/a> series about SQL Server Joins. Make sure to let me know how I am doing or ask your burning join related questions by leaving a comment below.\n<\/p>\n<p>\nOver the next few days we are going to look at the join algorithms in a little more detail. There are three join algorithms that are commonly implemented by modern database management systems. They are: Nested Loops Join, Hash Join and Sort Merge Join. Unsurprisingly, SQL Server also implements those three algorithms.\n<\/p>\n<p>\nToday's topic is the Loop Join &ndash; probably the simplest of them all.\n<\/p>\n<h3>The Nested Loops Join<\/h3>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png\" alt=\"nested loops join icon\" title=\"nested loops join icon\" width=\"200\" height=\"105\" class=\"aligncenter size-full wp-image-1476\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png 200w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon-150x78.png 150w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a>\n<\/p>\n<p>\nThe Nested Loop Algorithm gets its name from the fact that it literally executes two nested loops. The outer loop steps through the rows of the left side. For each row the inner loop then steps through all rows of the right side to find all matches. That means the entire right side input is accessed as many times as there are rows on the left. To demonstrate that, let's create these two tables:\n<\/p>\n<div>\n[sql]\nIF OBJECT_ID('dbo.Tbl10') IS NOT NULL DROP TABLE dbo.Tbl10;<br \/>\nCREATE TABLE dbo.Tbl10(<br \/>\n  Id INT IDENTITY(1,1),<br \/>\n  Val INT,<br \/>\n  Fill CHAR(7000) NOT NULL DEFAULT REPLICATE('Fill',1750)<br \/>\n);<\/p>\n<p>IF OBJECT_ID('dbo.Tbl100') IS NOT NULL DROP TABLE dbo.Tbl100;<br \/>\nCREATE TABLE dbo.Tbl100(<br \/>\n  Id INT IDENTITY(1,1),<br \/>\n  Val INT,<br \/>\n  Fill CHAR(7000) NOT NULL DEFAULT REPLICATE('Fill',1750)<br \/>\n);<\/p>\n<p>INSERT INTO dbo.Tbl10(Val)<br \/>\nSELECT TOP(10) 1+ROW_NUMBER()OVER(ORDER BY (SELECT 1))%100<br \/>\nFROM sys.all_columns A, sys.all_columns B, sys.all_columns C;<\/p>\n<p>SELECT index_type_desc, alloc_unit_type_desc, index_depth, page_count, record_count<br \/>\nFROM sys.dm_db_index_physical_stats(DB_ID(),OBJECT_ID('dbo.Tbl10'),NULL,NULL,'SAMPLED');<\/p>\n<p>INSERT INTO dbo.Tbl100(Val)<br \/>\nSELECT TOP(100) ROW_NUMBER()OVER(ORDER BY (SELECT 1))<br \/>\nFROM sys.all_columns A, sys.all_columns B, sys.all_columns C;<\/p>\n<p>SELECT index_type_desc, alloc_unit_type_desc, index_depth, page_count, record_count<br \/>\nFROM sys.dm_db_index_physical_stats(DB_ID(),OBJECT_ID('dbo.Tbl100'),NULL,NULL,'SAMPLED');<br \/>\n[\/sql]\n<\/p><\/div>\n<p>\nAfter executing this, the <span class=\"tt\">dbo.Tbl100<\/span> table contains 100 records. The <span class=\"tt\">dbo.Tbl10<\/span> contains 10 records. Both tables are designed so that each record takes up an entire storage page of 8192 bytes. The two selects against the <span class=\"tt\">sys.dm_db_index_physical_stats<\/span> show the amount of pages used by and the amount of records stored in each table:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-example-tables.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-example-tables.jpg\" alt=\"create example tables\" title=\"create example tables\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1474\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-example-tables.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-example-tables-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-example-tables-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-example-tables-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<p>\nThe query also shows that both tables do not have a clustered index. Now let's run the following query:\n<\/p>\n<div>\n[sql]\nSET STATISTICS IO ON;<br \/>\nGO<br \/>\nSELECT *<br \/>\nFROM dbo.Tbl100 A<br \/>\nINNER LOOP JOIN dbo.Tbl10 B<br \/>\nON A.Val = B.Val;<br \/>\nGO<br \/>\nSET STATISTICS IO OFF;<br \/>\n[\/sql]\n<\/div>\n<p>\nThe query returns ten records. Because we used the <span class=\"tt\">LOOP<\/span> hint, the Nested Loops Join algorithm was used:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/heap-nested-loops-join-execution-plan.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/heap-nested-loops-join-execution-plan.jpg\" alt=\"execution plan for nested loops join aigorithm\" title=\"execution plan for nested loops join aigorithm\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1475\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/heap-nested-loops-join-execution-plan.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/heap-nested-loops-join-execution-plan-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/heap-nested-loops-join-execution-plan-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/heap-nested-loops-join-execution-plan-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<p>\nYou can see in the tooltip that the table scan of <span class=\"tt\">dbo.Tbl10<\/span> was executed 100 times, once for each row in <span class=\"tt\">dbo.Tbl100<\/span>. Looking at the output of <span class=\"tt\">SET STATISTICS IO ON;<\/span> confirms that:\n<\/p>\n<div>\n[sourcecode]\nTable 'Tbl10'. Scan count 1, logical reads 1000, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\nTable 'Tbl100'. Scan count 1, logical reads 100, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\n[\/sourcecode]\n<\/div>\n<p>\nThe query executed 1,000 reads against the 10 page table, so the entire table was read 100 times.\n<\/p>\n<p>\nThis sounds pretty bad. So why would you ever want to use the Nested Loops Join algorithm? There are a quite a few advantages. See the Strengths and Weaknesses section at the end of this article for a detailed list.\n<\/p>\n<p>\nThe biggest advantage is probably that there is no setup work required. If the tables are small enough, the nested join can be done processing, before the other algorithms would have even started returning results.\n<\/p>\n<p>\nYou also need to keep in mind that the above example was the worst case scenario of joining two heaps with no usable indexes. So, let's see what happens if we add a clustered index:\n<\/p>\n<div>\n[sql]\nCREATE UNIQUE CLUSTERED INDEX [dbo.Tbl10(Val, Id) CL] ON dbo.Tbl10(Val, Id);<br \/>\n[\/sql]\n<\/div>\n<p>\nNow <span class=\"tt\">sys.dm_db_index_physical_stats<\/span> shows an index depth of two:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-clustered-index-on-Tbl10.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-clustered-index-on-Tbl10.jpg\" alt=\"create clustered index on Tbl10\" title=\"create clustered index on Tbl10\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1473\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-clustered-index-on-Tbl10.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-clustered-index-on-Tbl10-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-clustered-index-on-Tbl10-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/create-clustered-index-on-Tbl10-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<p>\nThe index depth is what determines how many reads are required to do a seek in that index. If we rerun the above join query again the execution plan will, as expected, contain a seek of <span class=\"tt\">dbo.Tbl10<\/span>:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-with-seek.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-with-seek.jpg\" alt=\"nested loops join with seek\" title=\"nested loops join with seek\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1472\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-with-seek.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-with-seek-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-with-seek-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-with-seek-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<p>\nThis execution plan now is not quite a nested loop anymore. SQL Server still loops through the left input one row at a time. But it does not loop through the second input anymore. Instead it executes a direct seek to read just the row requested. However, the seek operation is still executed 100 times. So we can expect 200 reads to happen against that table. Let's check the <span class=\"tt\">SET STATISTICS IO ON;<\/span> output:\n<\/p>\n<div>\n[sourcecode]\nTable 'Tbl10'. Scan count 100, logical reads 227, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\nTable 'Tbl100'. Scan count 1, logical reads 100, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\n[\/sourcecode]\n<\/div>\n<p>\nIt shows 227 reads. There are just a few reads more than we expected. Those additional reads happen because of additional meta-data pages like the IAM page that need to be accessed.\n<\/p>\n<p>\nWith an appropriate index the Nested Loops Join algorithm is not that bad anymore. While the savings in this case weren't great, you need to keep in mind, that the index depth growth very slowly as new rows are added to the table. Even in this badly designed example table you can store several million rows before a seek takes more than four reads.\n<\/p>\n<p>\nThis example showed another advantage of the Nested Loops Join operator: It can make use of an index on the right side input. With the exception of a few edge cases, the other two algorithms cannot utilize such an index.\n<\/p>\n<p>\nIf you are following along with the examples, use this statement to remove the index when you are done:\n<\/p>\n<div>\n[sql]\nDROP INDEX dbo.Tbl10.[dbo.Tbl10(Val, Id) CL];<br \/>\n[\/sql]\n<\/div>\n<h3>Loop Join Strengths and Weaknesses<\/h3>\n<p>\nThe Loop Join operator has the following strength and weaknesses:<\/p>\n<ul>\n<li>+ There is no setup cost.<\/li>\n<li>+ It does not require memory.<\/li>\n<li>+ The first rows are returned immediately, as soon as a match is found.<\/li>\n<li>+ It is the only algorithm that can handle a plain nonequi-join situation.<\/li>\n<li>+ A matching index on the right input can be utilized, potentially saving a lot of reads.<\/li>\n<li>- If there is no usable index available the right input has to be read completely for each row of the left input \u2013 making this algorithm very expensive, at least on large data sets.<\/li>\n<\/ul>\n<h3>Summary<\/h3>\n<p>\nThe Nested Loops Join algorithm is SQL Servers default join operator. This is due to its simplicity. There are no setup costs and its execution does not require memory. Because of that, it produces the first rows fairly quickly which can be an advantage in certain cases. This algorithm is also the only one that can truly handle a plain nonequi-join. Finally, it can make use of an index on the right input side, which sets it apart from the other algorithms.\n<\/p>\n<h3>A Join A Day<\/h3>\n<p>\nThis post is part of my December 2012 \"A Join A Day\" blog post series. You can find the table of contents with all posts published so far in the introductory post: <a href=\"http:\/\/sqlity.net\/en\/1146\/a-join-a-day-introduction\/\">A Join A Day \u2013 Introduction<\/a>. Check back there frequently throughout the month.\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article introduces the Nested Loops Join algorithm. It shows its strengths and weaknesses to help you identify query situations for which the Nested Loops Join operator in the execution plan is an appropriate choice.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[28,5,19,27,14],"tags":[],"class_list":["post-1471","post","type-post","status-publish","format-standard","hentry","category-a-join-a-day","category-general","category-performance","category-series","category-sql-server-internals"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A Join A Day \u2013 The Nested Loops Join - sqlity.net<\/title>\n<meta name=\"description\" content=\"This article introduces the Nested Loops Join algorithm. It shows its strengths and weaknesses to help you identify query situations for which the Nested Loops Join operator in the execution plan is an appropriate choice.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Join A Day \u2013 The Nested Loops Join - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"This article introduces the Nested Loops Join algorithm. It shows its strengths and weaknesses to help you identify query situations for which the Nested Loops Join operator in the execution plan is an appropriate choice.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/\" \/>\n<meta property=\"og:site_name\" content=\"sqlity.net\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sqlity.net\" \/>\n<meta property=\"article:published_time\" content=\"2012-12-21T15:00:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T18:50:34+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png\" \/>\n<meta name=\"author\" content=\"Sebastian Meine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sqlity\" \/>\n<meta name=\"twitter:site\" content=\"@sqlity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sebastian Meine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"A Join A Day \u2013 The Nested Loops Join\",\"datePublished\":\"2012-12-21T15:00:02+00:00\",\"dateModified\":\"2014-11-13T18:50:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/\"},\"wordCount\":1283,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/nested-loops-join-icon.png\",\"articleSection\":[\"A Join A Day\",\"General\",\"Performance\",\"Series\",\"SQL Server Internals\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/\",\"name\":\"A Join A Day \u2013 The Nested Loops Join - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/nested-loops-join-icon.png\",\"datePublished\":\"2012-12-21T15:00:02+00:00\",\"dateModified\":\"2014-11-13T18:50:34+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"This article introduces the Nested Loops Join algorithm. It shows its strengths and weaknesses to help you identify query situations for which the Nested Loops Join operator in the execution plan is an appropriate choice.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#primaryimage\",\"url\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/nested-loops-join-icon.png\",\"contentUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/nested-loops-join-icon.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1471\\\/a-join-a-day-the-nested-loops-join\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Join A Day \u2013 The Nested Loops Join\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\",\"name\":\"sqlity.net\",\"description\":\"Quality for SQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sqlity.net\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\",\"name\":\"Sebastian Meine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"caption\":\"Sebastian Meine\"},\"sameAs\":[\"http:\\\/\\\/sqlity.net\",\"https:\\\/\\\/x.com\\\/sqlity\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A Join A Day \u2013 The Nested Loops Join - sqlity.net","description":"This article introduces the Nested Loops Join algorithm. It shows its strengths and weaknesses to help you identify query situations for which the Nested Loops Join operator in the execution plan is an appropriate choice.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/","og_locale":"en_US","og_type":"article","og_title":"A Join A Day \u2013 The Nested Loops Join - sqlity.net","og_description":"This article introduces the Nested Loops Join algorithm. It shows its strengths and weaknesses to help you identify query situations for which the Nested Loops Join operator in the execution plan is an appropriate choice.","og_url":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2012-12-21T15:00:02+00:00","article_modified_time":"2014-11-13T18:50:34+00:00","og_image":[{"url":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png","type":"","width":"","height":""}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"A Join A Day \u2013 The Nested Loops Join","datePublished":"2012-12-21T15:00:02+00:00","dateModified":"2014-11-13T18:50:34+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/"},"wordCount":1283,"commentCount":0,"image":{"@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png","articleSection":["A Join A Day","General","Performance","Series","SQL Server Internals"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/","url":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/","name":"A Join A Day \u2013 The Nested Loops Join - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png","datePublished":"2012-12-21T15:00:02+00:00","dateModified":"2014-11-13T18:50:34+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"This article introduces the Nested Loops Join algorithm. It shows its strengths and weaknesses to help you identify query situations for which the Nested Loops Join operator in the execution plan is an appropriate choice.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#primaryimage","url":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png","contentUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/nested-loops-join-icon.png"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/1471\/a-join-a-day-the-nested-loops-join\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"A Join A Day \u2013 The Nested Loops Join"}]},{"@type":"WebSite","@id":"https:\/\/sqlity.net\/en\/#website","url":"https:\/\/sqlity.net\/en\/","name":"sqlity.net","description":"Quality for SQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sqlity.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c","name":"Sebastian Meine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","caption":"Sebastian Meine"},"sameAs":["http:\/\/sqlity.net","https:\/\/x.com\/sqlity"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-nJ","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/comments?post=1471"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1471\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=1471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=1471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=1471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}