Databases Reference
In-Depth Information
•
Create better indexes.
Having a good indexing strategy is important. The order of your
columns and the number of columns can make a world of difference for SQL Database. This
chapter reviews indexing shortly.
■
to run the following examples, you need to execute the
tuning.sql
script available on the topic's download
page. it creates a few sample tables with test data. make sure to select a user database when running this script.
Note
To show which physical
JOIN
operators have been selected, execution plans provide insights into the volume of
data being worked on and the relative cost of certain operations. For example, execute the following SQL statement
(after running the
tuning.sql
script):
SELECT T.Name, T.UserType
FROM TestUsers T INNER JOIN TestUserType UT
ON T.UserType = UT.UserType
WHERE T.AgeGroup > 0 AND UT.UserTypeKey = 'Manager'
This statement returns 25 rows. To view the execution plan, you need to request it before running the statement.
Either press Ctrl + M or choose Query
➤
Include Actual Execution Plan from the menu in SQL Server Management
Studio, and re-run the SQL statement. You should now see an Execution Plan tab. Click the tab to see output similar to
that shown in Figure
11-2
.
Figure 11-2.
Sample execution plan, not tuned
In order to fully understand the previous execution plan, let's review additional symbols often seen in execution
plans. Table
11-5
shows a few symbols provided by SSMS that have clear performance implications.