Databases Reference
In-Depth Information
When you run this batch, rather than see a third tab displayed in SSMS, you will see that there are
now two result sets in the query's Results tab. The i rst is the output from running the query, and
the second is the text output for this plan, which looks something like what is shown in Figure 5-14.
FIGURE 5-14
NOTE Figure 5-14 shows only some of the columns in the result set, as there are
too many columns returned to i t onto a single screen.
The following example shows some of the content of the StmtText column, which illustrates what
the query plan looks like, just as in the graphical plan but this time in a textual format:
|--Sort(ORDER BY:([Expr1003] DESC))
|--Compute Scalar(DEFINE:([Expr1003 ...
|--Hash Match(Aggregate, ...
|--Index Scan(OBJECT:( ...
NOTE The preceding output has been selectively edited to i t into the available
space.
As mentioned before, this is read from the bottom up. You can see that the i rst operator is the clus-
tered index scan, which is the same operator shown in Figure 5-6. From there (working up), the next
operator is the hash match, followed by the compute scalar operator, and then the sort operator.
While the query you examined may seem pretty simple, you have noticed that even for this query,
the Query Optimizer has quite a bit of work to do. As a follow-up exercise, try adding one index at
Search WWH ::




Custom Search