{"id":1509,"date":"2012-12-26T10:00:58","date_gmt":"2012-12-26T15:00:58","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=1509"},"modified":"2012-12-25T12:51:28","modified_gmt":"2012-12-25T17:51:28","slug":"a-join-a-day-loop-join-limitations","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/","title":{"rendered":"A Join A Day \u2013 Loop Join Limitations"},"content":{"rendered":"<div>\n<h3>Introduction<\/h3>\n<p>\nThis is the twenty-sixth 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 three days I am going to look at what is possible and what is not possible with each join algorithm. This information can help to understand why the optimizer might have made a particular choice. I am going to start out with the Loop Join algorithm.\n<\/p>\n<h3>Loop Join<\/h3>\n<p>\nAs we have seen before, there are nine logical join types. With the exception of the cross join, each one can be executed either as equi-join or as nonequi-join. The following is a list of example queries for each combination together with their execution plans. All nonequi-join queries are plain nonequi-joins without any equality columns. Because mixed joins are handled just like equi-joins with an additional filter step, there are no mixed examples included here.\n<\/p>\n<h4>Cross Loop Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg\" alt=\"cross-loop-join\" title=\"cross-loop-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1518\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a><\/p>\n<h4>Inner Loop Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-equi-join.jpg\" alt=\"inner-loop-equi-join\" title=\"inner-loop-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1521\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-equi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-equi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-equi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-equi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a><\/p>\n<h4>Left Loop Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-equi-join.jpg\" alt=\"left-loop-equi-join\" title=\"left-loop-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1512\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-equi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-equi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-equi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-equi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a> <\/p>\n<h4>Right Loop Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-equi-join.jpg\" alt=\"right-loop-equi-join\" title=\"right-loop-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1516\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-equi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-equi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-equi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-equi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a><\/p>\n<h4>Full Loop Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-equi-join.jpg\" alt=\"full-loop-equi-join\" title=\"full-loop-equi-join\" width=\"1093\" height=\"715\" class=\"aligncenter size-full wp-image-1519\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-equi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-equi-join-300x196.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-equi-join-1024x669.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-equi-join-150x98.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a><\/p>\n<h4>Left Semi Loop Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-equi-join.jpg\" alt=\"left-semi-loop-equi-join\" title=\"left-semi-loop-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1514\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-equi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-equi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-equi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-equi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a><\/p>\n<h4> Right Semi Loop Equi-Join<\/h4>\n<p>\nN\/A\n<\/p>\n<h4>Left Anti Semi Loop Equi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-equi-join.jpg\" alt=\"left-anti-semi-loop-equi-join\" title=\"left-anti-semi-loop-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1510\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-equi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-equi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-equi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-equi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<h4>Right Anti Semi Loop Equi-Join<\/h4>\n<p>\nN\/A\n<\/p>\n<h4>Inner Loop Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-nonequi-join.jpg\" alt=\"inner-loop-nonequi-join\" title=\"inner-loop-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1522\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-nonequi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-nonequi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-nonequi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-loop-nonequi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<h4>Left Loop Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-nonequi-join.jpg\" alt=\"left-loop-nonequi-join\" title=\"left-loop-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1513\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-nonequi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-nonequi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-nonequi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-loop-nonequi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<h4>Right Loop Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-nonequi-join.jpg\" alt=\"right-loop-nonequi-join\" title=\"right-loop-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1517\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-nonequi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-nonequi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-nonequi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-loop-nonequi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<h4>Full Loop Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-nonequi-join.jpg\" alt=\"full-loop-nonequi-join\" title=\"full-loop-nonequi-join\" width=\"1093\" height=\"689\" class=\"aligncenter size-full wp-image-1520\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-nonequi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-nonequi-join-300x189.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-nonequi-join-1024x645.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-loop-nonequi-join-150x94.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<h4>Left Semi Loop Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-nonequi-join.jpg\" alt=\"left-semi-loop-nonequi-join\" title=\"left-semi-loop-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1515\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-nonequi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-nonequi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-nonequi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-loop-nonequi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<h4> Right Semi Loop Nonequi-Join<\/h4>\n<p>\nN\/A\n<\/p>\n<h4>Left Anti Semi Loop Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-nonequi-join.jpg\" alt=\"left-anti-semi-loop-nonequi-join\" title=\"left-anti-semi-loop-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1511\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-nonequi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-nonequi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-nonequi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-loop-nonequi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<h4>Right Anti Semi Loop Nonequi-Join<\/h4>\n<p>\nN\/A\n<\/p>\n<\/p>\n<h3>Observations<\/h3>\n<p>\nThe loop join is the universal join algorithm. It can handle almost any situation including the join-condition-free cross join. It even does not care if the query is an equi- or a nonequi-join. However, it cannot handle any right sided logical join. Because the algorithm always goes through the left side one row at a time and then tries to find matches on the right side for each of them, it cannot keep track of which right side rows have been used and which ones haven't. Therefore any forced right side loop join request will fail as you can see in the examples above. However, there is no statement or hint that forces a semi join and particularly there is no way to write a \"right semi\" query. The only way to get to one of those is if the optimizer decides that a rearrangement of the tables will improve performance. Because the Loop Join algorithm can't handle any right side join, any query for which SQL Server decides to use a semi join operator will end up using a left semi operator. The same conclusion can be drawn for the anti semi joins. Because of that I did not included examples for the four different right-(anti-)semi conditions above.\n<\/p>\n<p>\nFor the same reason that prevents a right outer loop join, a full outer loop join is also not possible. However, there are situations (as we will see over the next two days) that can only be handled by the Loop Join operator, so the optimizer has to come up with a workaround for this problem. If faced with a query that requires a loop join and also requires a full join, the optimizer rewrites the query from <span class=\"tt\">Tbl1 FULL LOOP JOIN Tbl2<\/span> to <span class=\"tt\">Tbl1 LEFT LOOP JOIN Tbl2 UNION ALL Tbl2 WHERE NOT EXISTS(Tbl1)<\/span>. This rewrite leads to a very expensive query plan potentially causing <span class=\"tt\">Tbl1<\/span> to be scanned once for each row in <span class=\"tt\">Tbl2<\/span> and additionally <span class=\"tt\">Tbl2<\/span> to be scanned once for each row in <span class=\"tt\">Tbl1<\/span>. Let's look at a quick example:\n<\/p>\n<div>\n[sql]\nSET STATISTICS IO ON;<br \/>\nGO<br \/>\nSELECT *<br \/>\nFROM dbo.Tbl100 A<br \/>\nFULL 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>\nRemember, both tables have as many pages as they have rows:\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 captured statistics look like this:\n<\/p>\n<div>\n[sourcecode]\nTable 'Tbl100'. Scan count 2, logical reads 1100, physical reads 0, read-ahead reads 94, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\nTable 'Tbl10'. Scan count 2, logical reads 1010, physical reads 2, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\n[\/sourcecode]\n<\/div>\n<p>\n<span class=\"tt\">Tbl100<\/span> shows 1100 logical reads or 11 times its size and <span class=\"tt\">Tbl10<\/span> shows 1010 logical reads or 101 times its size. So, if you run into a full outer join that has to be handled by a loop join, it is even more important that both tables are adequately indexed.\n<\/p>\n<p>\nFinally, all nonequi queries contain an additional Spool operator. The Spool operator creates a copy of the data, including only columns that are actually needed, in <span class=\"tt\">tempdb<\/span>. This is an attempt to make the inevitable scan less pain-full. Because these queries do not have an equality condition, any index would be only of marginal help. So, if you have a lot of nonequi-join queries make sure your <span class=\"tt\">tempdb<\/span> is as finely tuned as possible. Things to check for first in this context are the number of <span class=\"tt\">tempdb<\/span> files and placement of such on a separate disk that is as fast as possible.\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>Which logical join types can be handled by the Loop Join operator and which can&#8217;t? Where does the optimizer have to jump through hoops to generate a query plan? This article gives answers to these questions.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/\">[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,27,14],"tags":[],"class_list":["post-1509","post","type-post","status-publish","format-standard","hentry","category-a-join-a-day","category-general","category-series","category-sql-server-internals"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A Join A Day \u2013 Loop Join Limitations - sqlity.net<\/title>\n<meta name=\"description\" content=\"Which logical join types can be handled by the Loop Join operator and which can&#039;t? Where does the optimizer have to jump through hoops to generate a query plan? This article gives answers to these questions.\" \/>\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\/1509\/a-join-a-day-loop-join-limitations\/\" \/>\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 Loop Join Limitations - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"Which logical join types can be handled by the Loop Join operator and which can&#039;t? Where does the optimizer have to jump through hoops to generate a query plan? This article gives answers to these questions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/\" \/>\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-26T15:00:58+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"A Join A Day \u2013 Loop Join Limitations\",\"datePublished\":\"2012-12-26T15:00:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/\"},\"wordCount\":895,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-loop-join.jpg\",\"articleSection\":[\"A Join A Day\",\"General\",\"Series\",\"SQL Server Internals\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/\",\"name\":\"A Join A Day \u2013 Loop Join Limitations - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-loop-join.jpg\",\"datePublished\":\"2012-12-26T15:00:58+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"Which logical join types can be handled by the Loop Join operator and which can't? Where does the optimizer have to jump through hoops to generate a query plan? This article gives answers to these questions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#primaryimage\",\"url\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-loop-join.jpg\",\"contentUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-loop-join.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1509\\\/a-join-a-day-loop-join-limitations\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Join A Day \u2013 Loop Join Limitations\"}]},{\"@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 Loop Join Limitations - sqlity.net","description":"Which logical join types can be handled by the Loop Join operator and which can't? Where does the optimizer have to jump through hoops to generate a query plan? This article gives answers to these questions.","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\/1509\/a-join-a-day-loop-join-limitations\/","og_locale":"en_US","og_type":"article","og_title":"A Join A Day \u2013 Loop Join Limitations - sqlity.net","og_description":"Which logical join types can be handled by the Loop Join operator and which can't? Where does the optimizer have to jump through hoops to generate a query plan? This article gives answers to these questions.","og_url":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2012-12-26T15:00:58+00:00","og_image":[{"url":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg","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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"A Join A Day \u2013 Loop Join Limitations","datePublished":"2012-12-26T15:00:58+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/"},"wordCount":895,"commentCount":0,"image":{"@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg","articleSection":["A Join A Day","General","Series","SQL Server Internals"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/","url":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/","name":"A Join A Day \u2013 Loop Join Limitations - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg","datePublished":"2012-12-26T15:00:58+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"Which logical join types can be handled by the Loop Join operator and which can't? Where does the optimizer have to jump through hoops to generate a query plan? This article gives answers to these questions.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#primaryimage","url":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg","contentUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-loop-join.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"A Join A Day \u2013 Loop Join Limitations"}]},{"@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-ol","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1509","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=1509"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1509\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=1509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=1509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}