Databases Reference
In-Depth Information
Parallelism will be considered when the estimated cost of a serial plan is higher than the
value defined in the cost threshold for the parallelism configuration parameter. However,
this doesn't guarantee that parallelism will actually be employed in the final execution
plan, as the final decision to parallelize a query (or not) will be based on cost reasons. That
is, there is no guarantee that the best parallel plan found will have a lower cost than the
best serial plan, so the serial plan may still end up being the better plan. Parallelism is
implemented by the parallelism physical operator, also known as the exchange operator,
which implements the
Distribute Streams
,
Gather Streams
, and
Repartition Streams
logical operations.
The following query, which lists the names and cities of all the individual customers
ordered by
CustomerID
, will produce a parallel plan. Since this plan is too big to print in
this topic, only a section is displayed in Figure 2-31.
SELECT
I
.
CustomerID
,
C
.
FirstName
,
C
.
LastName
,
A
.
City
FROM
Person
.
Contact
AS
C
JOIN
Sales
.
Individual
AS
I
ON
C
.
ContactID
=
I
.
ContactID
JOIN
Sales
.
CustomerAddress
AS
CA
ON
CA
.
CustomerID
=
I
.
CustomerID
JOIN
Person
.
Address
AS
A
ON
A
.
AddressID
=
CA
.
AddressID
ORDER
BY
I
.
CustomerID
Listing 2-33.
Figure 2-31:
Part of a parallel plan.