Problem Statement
Which join algorithm is typically best when both inputs are already sorted on the join key?
Explanation
Merge join streams through two sorted inputs and matches rows in order. When both sides are sorted (or cheap to sort) it can be very fast and memory-friendly.
Hash join excels with large, unsorted sets and equality predicates. Nested loops shine when the outer is small and the inner has an efficient seek.
Code Solution
SolutionRead Only
/* Engine chooses merge when indexes support order: JOIN ON t1.k = t2.k with both indexed by k */
Practice Sets
This question appears in the following practice sets:
