Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

105


Chapter 5: SQL Server Management and Development Tools


5


What makes the query execution plans even more important is that SQL is a descriptive
language, so it doesn’t tell the Query Optimizer exactly how to get the data, but only
which data to retrieve. Although some performance tuning can be applied to the way
the query is stated, most of the tuning is accomplished by adjusting the indexes, which
greatly affects how the Query Optimizer can compile the query. The query execution
plan reveals how SQL Server optimizes the query, takes advantage of indexes, pulls data
from other data sources, and performs joins. Reading the query execution plans and
understanding their interaction with the database schema and indexes is both a science
and an art.

Chapter 44, “Interpreting Query Execution Plans,” includes a full discussion on reading the query
execution plan.

Query Editor can display either an estimated query execution plan prior to executing the
query or the actual plan after the query is run. Both display very similar plans; the major
differences (beside the wait) is that the actual plan can display both the estimated and
actual row counts for each operation, whereas the estimated query execution plan knows
about only the estimated rows counts.

In addition to the query execution plan, the Query Editor can display the client statistics,
which is a quick way to see the server execution times for the batch. (Although Profi ler is a
much better tool for detail work.) Enable Include Client Statistics using the Query menu or
toolbar to add this tab to the results.

Using the Solution Explorer ................................................................................


The optional Solution Explorer enables you to organize fi les and connections within
solutions, which then contain projects, similar to the Solution Explorer in Visual Studio.
You don’t need to use it; File ➪ Open and Save works well without Solution Explorer, but if
you work on several database projects, you may fi nd that Solution Explorer helps keep your
life organized — or at least your code organized. You can fi nd the Solution Explorer in the
View menu, and you can add the Solution Explorer icon to the Standard toolbar using the
Customize toolbar.

To use the Solution Explorer for managing query scripts, use the Solution Explorer context
menu to create a new project. This creates the nodes and directories for the fi les. When the
project exists, use it to create new queries.

Other than simply organizing your project, the Solution Explorer offers two practical ben-
efi ts. First, if queries are saved within a solution, bookmarks are retained. Secondly, the
Solution Explorer can be used with source control.

c05 July 23, 2012 11:44 AM V1

c05.indd 105c05.indd 105 7/30/2012 4:14:51 PM7/30/2012 4:14:51 PM


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