Databases Reference
In-Depth Information
Figure 7-1:
Execution plan using a Hash Join.
On the other hand, the following query will request the Query Optimizer to exclude
a Hash Join by requesting either a Nested Loops or Merge Join. In this case, the Query
Optimizer chooses a Merge Join, as shown in the plan in Figure 7-2.
SELECT
FirstName
,
LastName
FROM
Person
.
Contact
AS
C
JOIN
Sales
.
Individual
AS
I
ON
C
.
ContactID
=
I
.
ContactID
OPTION
(
LOOP
JOIN,
MERGE
JOIN)
Listing 7-2.
Figure 7-2:
Execution plan excluding a Hash Join.