Databases Reference
In-Depth Information
SELECT
FirstName
,
LastName
,
CustomerType
FROM
Person
.
Contact
AS
C
JOIN
Sales
.
Individual
AS
I
ON
C
.
ContactID
=
I
.
ContactID
JOIN
Sales
.
Customer
AS
Cu
ON
I
.
CustomerID
=
Cu
.
CustomerID
Listing 5-19.
After a logical tree is created for this query, as explained before, each operator is placed in
its own group, as shown in Table 5.7.
Group 6
Join 3 & 4
Group 5
Group 4
Scan Customer
Group 3
Join 1 & 2
Group 2
Scan Individual
Group 1
Scan Contact
Table 5-7:
Initial memo structure.
Notice how both joins reference the other groups instead of the operators. We call Group
6 the root because it is the root operator of the initial plan, that is, it is the root node of
the original query tree. I just left Group 5 blank so it is easier to introduce new groups and
visualize the root group at the top. During optimization, several transformation rules will
be executed, and they will create new alternatives. For example, if we apply either of the
two following associativity rules …