Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

116


Part II: Building Databases and Working with Data


As more complexity has been added to the SQL SELECT command over the years, how to
think through the logical fl ow has also become more complex. In various sources, you can
fi nd minor differences in how SQL professionals view the logical fl ow. That’s OK — it’s just a
way to think through a query.

As you begin to think in terms of the SQL SELECT statement, rather than in terms of the
graphical user interface, understanding the fl ow of SELECT and how to read the query
execution plan can help you think through and develop diffi cult queries.

Physical Flow of the Query Statement
SQL Server can take the SELECT statement and develop an optimized query execution plan,
which may not be in the execution order you would guess (see Figure 6-3). The indexes
available to the SQL Server Query Optimizer also affect the query execution plan, as
explained in Chapter 45, “Indexing Strategies.”

FIGURE 6-3
The physical execution plan is different from the syntactical order, or logical understanding, of the query.

c06.indd 116c06.indd 116 7/30/2012 4:15:58 PM7/30/2012 4:15:58 PM


http://www.it-ebooks.info
Free download pdf