Merge Joins
A Merge Join operator represents a Merge Join in the execution plan. Merge joins are typically used to join two large input tables that have indexes to support the join. In a Merge Join, the size of the Outer and Inner Table doesn't affect the cost of the join, but both input tables must be sorted in the same order for the join to work. A row is retrieved from the Outer Table, then matched with rows from the Inner Table and the results output. Once all the matches have been exhausted on the Inner Table, SQL Server moves to the next row in the Outer Table. Since both the Inner and Outer Tables are sorted in the same order going into the merge join operation, the output is returned in the same order.
The following diagram depicts ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access