{"id":1529,"date":"2012-12-27T10:00:10","date_gmt":"2012-12-27T15:00:10","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=1529"},"modified":"2014-11-13T13:50:07","modified_gmt":"2014-11-13T18:50:07","slug":"a-join-a-day-merge-join-limitations","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/","title":{"rendered":"A Join A Day \u2013 Merge Join Limitations"},"content":{"rendered":"<div>\n<h3>Introduction<\/h3>\n<p>\nThis is the twenty-seventh 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>\nThe second join algorithm we are going to dissect further is the Merge Join algorithm: Today we are going to look at which situations can and which situations cannot be handled by the Merge Join operator.\n<\/p>\n<h3>Merge Join<\/h3>\n<p>\nAs we did for the <a href=\"http:\/\/sqlity.net\/en\/1509\/a-join-a-day-loop-join-limitations\/\">Loop Join algorithm<\/a>, we are going to look at all nine logical joins, each as equi- and as nonequi-join. The following is a list of example queries for each combination together with their execution plans. We are also going to look only at plain equi-join or nonequi-join scenarios and not include mixed cases, as those are handled similarly to equi-joins.\n<\/p>\n<h4>Cross Merge Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-join.jpg\" alt=\"cross-merge-join\" title=\"cross-merge-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1518\" \/><\/a><\/p>\n<h4>Inner Merge Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-merge-equi-join.jpg\" alt=\"inner-merge-equi-join\" title=\"inner-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1521\" \/><\/a><\/p>\n<h4>Left Merge Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-merge-equi-join.jpg\" alt=\"left-merge-equi-join\" title=\"left-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1512\" \/><\/a> <\/p>\n<h4>Right Merge Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-merge-equi-join.jpg\" alt=\"right-merge-equi-join\" title=\"right-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1516\" \/><\/a><\/p>\n<h4>Full Merge Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-merge-equi-join.jpg\" alt=\"full-merge-equi-join\" title=\"full-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1519\" \/><\/a><\/p>\n<h4>Left Semi Merge Equi-Join<\/h4>\n<p><a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-merge-equi-join.jpg\" alt=\"left-semi-merge-equi-join\" title=\"left-semi-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1514\" \/><\/a>\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-distinct-sort-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-distinct-sort-merge-equi-join.jpg\" alt=\"left-semi-distinct-sort-merge-equi-join\" title=\"left-semi-distinct-sort-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1530\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-distinct-sort-merge-equi-join.jpg 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-distinct-sort-merge-equi-join-300x157.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-distinct-sort-merge-equi-join-1024x536.jpg 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-distinct-sort-merge-equi-join-150x78.jpg 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-unique-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-unique-merge-equi-join.jpg\" alt=\"left-semi-unique-merge-equi-join\" title=\"left-semi-unique-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1514\" \/><\/a>\n<\/p>\n<h4> Right Semi Merge Equi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-semi-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-semi-merge-equi-join.jpg\" alt=\"right-semi-merge-equi-join\" title=\"right-semi-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1514\" \/><\/a>\n<\/p>\n<h4>Left Anti Semi Merge Equi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-merge-equi-join.jpg\" alt=\"left-anti-semi-merge-equi-join\" title=\"left-anti-semi-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1510\" \/><\/a>\n<\/p>\n<h4>Right Anti Semi Merge Equi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-anti-semi-merge-equi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-anti-semi-merge-equi-join.jpg\" alt=\"right-anti-semi-merge-equi-join\" title=\"right-anti-semi-merge-equi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1510\" \/><\/a>\n<\/p>\n<h4>Inner Merge Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-merge-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/inner-merge-nonequi-join.jpg\" alt=\"inner-merge-nonequi-join\" title=\"inner-merge-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1522\" \/><\/a>\n<\/p>\n<h4>Left Merge Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-merge-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-merge-nonequi-join.jpg\" alt=\"left-merge-nonequi-join\" title=\"left-merge-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1513\" \/><\/a>\n<\/p>\n<h4>Right Merge Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-merge-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/right-merge-nonequi-join.jpg\" alt=\"right-merge-nonequi-join\" title=\"right-merge-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1517\" \/><\/a>\n<\/p>\n<h4>Full Merge Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-merge-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-merge-nonequi-join.jpg\" alt=\"full-merge-nonequi-join\" title=\"full-merge-nonequi-join\" width=\"1093\" height=\"689\" class=\"aligncenter size-full wp-image-1520\" \/><\/a>\n<\/p>\n<h4>Left\/Right Semi Merge Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-merge-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-semi-merge-nonequi-join.jpg\" alt=\"left-semi-merge-nonequi-join\" title=\"left-semi-merge-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1515\" \/><\/a>\n<\/p>\n<h4>Left\/Right Anti Semi Merge Nonequi-Join<\/h4>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-merge-nonequi-join.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/left-anti-semi-merge-nonequi-join.jpg\" alt=\"left-anti-semi-merge-nonequi-join\" title=\"left-anti-semi-merge-nonequi-join\" width=\"1093\" height=\"573\" class=\"aligncenter size-full wp-image-1511\" \/><\/a>\n<\/p>\n<p>\nBoth Semi Nonequi-Join queries do not force a table order. Therefore the above two queries show that all four semi nonequi-join operations are not possible using the Merge Join operator.\n<\/p>\n<h3>Observations<\/h3>\n<p>\nThe most obvious shortfall of the Merge Join algorithm is related to nonequi-joins. The Merge Join algorithm requires at least one equality column pair in the join condition, as otherwise sorting \"in match order\" isn't possible. As there is no equality column in the join condition of a cross join either (it doesn't have a join condition after all), it seems obvious that the Merge Join algorithm can't handle that case either. But hold on &mdash; SQL Server's Merge Join operator is able to deal with a many-to-many full outer merge join scenario. Therefore a full outer merge nonequi-join situation can be handled as well.\n<\/p>\n<p>\nHowever, if you look at the properties for the Merge Join operator in the above image for the Full Merge Nonequi-join example query, you see that there is no join condition. The operator first does a complete cross join and then filters the rows afterwards using the residual condition. So that means, the Merge Join operator can handle a cross join too. But the optimizer team decided to not make it available in any other circumstance other than the many-to-many full outer join scenario. The reason for this decision is that it is a very expensive operation for the Merge Join operator to execute a cross join. Let's look at this example:\n<\/p>\n<div>\n[sql]\nSET STATISTICS IO ON;<br \/>\nSET STATISTICS TIME ON;<br \/>\nGO<br \/>\nSELECT  COUNT_BIG(1),MAX(.1*sod.SalesOrderID+.1*soh.SalesOrderID)<br \/>\nFROM Sales.SalesOrderHeader AS soh<br \/>\nFULL MERGE JOIN Sales.SalesOrderDetail AS sod<br \/>\nON soh.SalesOrderID != sod.SalesOrderID;<br \/>\nGO<br \/>\nSET STATISTICS TIME OFF;<br \/>\nSET STATISTICS IO OFF;<br \/>\nGO<br \/>\nSET STATISTICS IO ON;<br \/>\nSET STATISTICS TIME ON;<br \/>\nGO<br \/>\nSELECT  COUNT_BIG(1),MAX(.1*sod.SalesOrderID+.1*soh.SalesOrderID)<br \/>\nFROM Sales.SalesOrderHeader AS soh<br \/>\nFULL LOOP JOIN Sales.SalesOrderDetail AS sod<br \/>\nON soh.SalesOrderID != sod.SalesOrderID;<br \/>\nGO<br \/>\nSET STATISTICS TIME OFF;<br \/>\nSET STATISTICS IO OFF;<br \/>\n[\/sql]\n<\/div>\n<p>\nIt is the same query used in the examples above, just with an added aggregate to not have to return all those rows to the client. The first query is forcing the Merge Join operator; the second one is using the Loop Join operator:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-nonequi-join.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-nonequi-join.png\" alt=\"full nonequi join, merge vs. loop\" title=\"full nonequi join, merge vs. loop\" width=\"1093\" height=\"843\" class=\"aligncenter size-full wp-image-1585\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-nonequi-join.png 1093w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-nonequi-join-300x231.png 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-nonequi-join-1024x789.png 1024w, https:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/full-nonequi-join-150x115.png 150w\" sizes=\"auto, (max-width: 1093px) 100vw, 1093px\" \/><\/a>\n<\/p>\n<p>\nThese execution plans are actual plans captured with SQL Sentry Plan Explorer and show the actual row counts on the arrows connecting the operators.\n<\/p>\n<p>\nThe STATISTICS IO output is shown below:\n<\/p>\n<div>\n[sourcecode]\nTable 'Worktable'. Scan count 1, logical reads 12107191, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\nTable 'SalesOrderDetail'. Scan count 1, logical reads 228, physical reads 2, read-ahead reads 226, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\nTable 'SalesOrderHeader'. Scan count 1, logical reads 45, physical reads 30, read-ahead reads 43, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\n[\/sourcecode]\n<\/div>\n<div>\n[sourcecode]\nTable 'Worktable'. Scan count 2, logical reads 10398044, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\nTable 'SalesOrderHeader'. Scan count 2, logical reads 48, physical reads 22, read-ahead reads 82, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\nTable 'SalesOrderDetail'. Scan count 2, logical reads 456, physical reads 2, read-ahead reads 452, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<br \/>\n[\/sourcecode]\n<\/div>\n<p>\nBoth algorithms use a Worktable, but they seem to differ in size. The Worktable access happens inside of the Merge Join operator in the first query. The second query exposes it through Table Spool operators in the execution plan. While we can't directly access Worktables, we can see the number of reads executed against them. The Merge Join worktable requires about 20% more reads.\n<\/p>\n<p>\nThe above queries did not only capture IO statistics but also time statistics:\n<\/p>\n<div>\n[sourcecode]\nSQL Server Execution Times:<br \/>\n   CPU time = 6490765 ms,  elapsed time = 7580120 ms.<br \/>\n[\/sourcecode]\n<\/div>\n<div>\n[sourcecode]\nSQL Server Execution Times:<br \/>\n   CPU time = 2859920 ms,  elapsed time = 3191751 ms.<br \/>\n[\/sourcecode]\n<\/div>\n<p>\nThat is a factor of almost 2.4 that the loop join query is faster. So why would you use the Merge Join operator at all to execute a full outer many-to-many join?\n<\/p>\n<p>\nThe big difference between the two plans is that the loop join plan has to be broken down into two separate sections, each of which has to read the data from all the tables. If that read is very expensive, for example because the tables reside on a remote server, it can be advantageous to not have to do it twice. In a case like that the optimizer might chose to use the Merge Join operator instead of two Loop Join operators.\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>The Merge Join algorithm is the fastest in many cases. But how do I know what is possible and more importantly when it is not a good choice at all to use the Merge Join operator in an execution plan?<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-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-1529","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 v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A Join A Day \u2013 Merge Join Limitations - sqlity.net<\/title>\n<meta name=\"description\" content=\"The Merge Join algorithm is the fastest in many cases. But how do I know what is possible and more importantly when it is not a good choice at all to use the Merge Join operator in an execution plan?\" \/>\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\/1529\/a-join-a-day-merge-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 Merge Join Limitations - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"The Merge Join algorithm is the fastest in many cases. But how do I know what is possible and more importantly when it is not a good choice at all to use the Merge Join operator in an execution plan?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-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-27T15:00:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T18:50:07+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"A Join A Day \u2013 Merge Join Limitations\",\"datePublished\":\"2012-12-27T15:00:10+00:00\",\"dateModified\":\"2014-11-13T18:50:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/\"},\"wordCount\":995,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-merge-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\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/\",\"name\":\"A Join A Day \u2013 Merge Join Limitations - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-merge-join.jpg\",\"datePublished\":\"2012-12-27T15:00:10+00:00\",\"dateModified\":\"2014-11-13T18:50:07+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"The Merge Join algorithm is the fastest in many cases. But how do I know what is possible and more importantly when it is not a good choice at all to use the Merge Join operator in an execution plan?\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-join-limitations\\\/#primaryimage\",\"url\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-merge-join.jpg\",\"contentUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2012\\\/12\\\/cross-merge-join.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/1529\\\/a-join-a-day-merge-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 Merge 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 Merge Join Limitations - sqlity.net","description":"The Merge Join algorithm is the fastest in many cases. But how do I know what is possible and more importantly when it is not a good choice at all to use the Merge Join operator in an execution plan?","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\/1529\/a-join-a-day-merge-join-limitations\/","og_locale":"en_US","og_type":"article","og_title":"A Join A Day \u2013 Merge Join Limitations - sqlity.net","og_description":"The Merge Join algorithm is the fastest in many cases. But how do I know what is possible and more importantly when it is not a good choice at all to use the Merge Join operator in an execution plan?","og_url":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2012-12-27T15:00:10+00:00","article_modified_time":"2014-11-13T18:50:07+00:00","og_image":[{"url":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"A Join A Day \u2013 Merge Join Limitations","datePublished":"2012-12-27T15:00:10+00:00","dateModified":"2014-11-13T18:50:07+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/"},"wordCount":995,"commentCount":0,"image":{"@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-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\/1529\/a-join-a-day-merge-join-limitations\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/","url":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/","name":"A Join A Day \u2013 Merge Join Limitations - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-join.jpg","datePublished":"2012-12-27T15:00:10+00:00","dateModified":"2014-11-13T18:50:07+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"The Merge Join algorithm is the fastest in many cases. But how do I know what is possible and more importantly when it is not a good choice at all to use the Merge Join operator in an execution plan?","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-join-limitations\/#primaryimage","url":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-join.jpg","contentUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2012\/12\/cross-merge-join.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/1529\/a-join-a-day-merge-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 Merge 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_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-oF","jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1529","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=1529"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/1529\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=1529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=1529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=1529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}