Beruflich Dokumente
Kultur Dokumente
Reading
SQL Server 2012
Execution Plans
Module Overview
Execution Plan Core Concepts
Common Execution Plan Elements
Working with Execution Plans
Why does this query take so much longer than a very similar
query?
Types of operations
Order of operations
Choice of indexes
query
SQL Server does not execute the query, it just works out how
it would execute it
statistics
SET SHOWPLAN_TEXT ON
SET SHOWPLAN_ALL ON
Now deprecated
XML-based plans
SET SHOWPLAN_XML ON
Graphical plans
Elements
RID Lookup
Key Lookup
Can be used for left outer join, left semi join, left anti semi
join, right outer join, right semi join, right anti semi join and
union operations
Hash Match
Aggregations
Stream Aggregate
Highly efficient
Sort
Data Modification
INSERT
UPDATE
DELETE
Re-Executing Queries
Plan re-use is generally desirable
Correctness
Optimality
Functions)
sys.dm_exec_connections
sys.dm_exec_sessions
sys.dm_exec_query_stats
sys.dm_exec_requests
sys.dm_exec_sql_text()
sys.dm_exec_query_plan()
sys.dm_exec_cached_plans
sys.dm_exec_cached_plan_dependent_objects()
permits)
Logon information
Virtual machine
10776A-MIA-SQL1
User name
AdventureWorks\Administrator
Password
Pa$$w0rd
Lab Scenario
You have been learning about the design of indexes. To take
this learning further, you need to have a way to view how
these indexes are used.
In the first exercise, you will learn to view both estimated
and actual execution plans.
Execution plans can contain many types of elements. In the
second exercise, you will learn to identify the most common
plan elements and see how statements lead to these
elements being used.
You regularly find yourself trying to decide between
different ways of structuring SQL queries. You are
concerned that you arent always choosing the highestperforming options. If time permits, you will learn to use
execution plans to compare the cost of statements in multistatement batches.
Lab Review
Can two different queries end up with the same execution
plan?