9th ssn execution plans in microsoft sql server 2008 r2
1. SQL Saturday
9 th
Night
Execution Plans
Microsoft SQL Server 2008 R2
Σάββατο 26/03/2011
2. Η παρουςίαςη αυτή καταγράφεται ώςτε να είναι διαθέςιμη ςε
όςουσ θέλουν να την ξαναδούν, ή δεν είχαν την δυνατότητα να
την παρακολουθήςουν ςε πραγματικό χρόνο.
Η παρουςίαςη αυτή διατίθεται δωρεάν.
Εάν κάποιοσ από τουσ παραβριςκόμενουσ ςτην παρουςίαςη
αυτή έχει το οποιοδήποτε πρόβλημα ή αντίρρηςη να είναι μέςα
ςτην καταγραφή αυτήσ, παρακαλείται να αποχωρήςει άμεςα.
Σε διαφορετική περίπτωςη η παρουςία του εκλαμβάνεται ωσ
αποδοχή τησ καταγραφήσ.
Η παρουςίαςη αρχίζει ςε 1 λεπτό…
3. Antonios Chatzipavlis
Solution Architect - Principal Consultant
Development Evangelist - SQL Server MVP
MCT, MCITP, MCPD, MCSD, MCDBA, MCSA, MCTS, MCAD, MCP,
OCA
6. How a query executed
Basics of Execution Plans in Microsoft SQL Server 2008 R2
Relational Engine
QUERY
Query Parse/Query/Sequence Algebrizer Query Processor
Parsing Tree Output Process Tree Output
Query Optimizer
Estimated
Statistics Models
Execution Plan
Storage Engine
Query Actual
Execution Execution Plan
Actual
Execution Plan Plan Cache
Actual
Execution Plan
Actual
Execution Plan
Actual
Execution Plan
6
7. Estimated vs Actual Execution Plans
Basics of Execution Plans in Microsoft SQL Server 2008 R2
•
•
•
•
•
•
7
8. Execution Plan Reuse
Basics of Execution Plans in Microsoft SQL Server 2008 R2
• (previously called Procedure Cache)
• Each plan is stored once in Plan Cache
• Except if the optimizer sees parallelism, in this case one query gets two
plans.
• Execution Plans are not kept in memory forever.
• Slowly aged out of the system using an “age” formula
• Estimated Cost X Number of Times it has been used
• Lazywriter process periodically scans the cache and decreases this
value by one each time.
8
16. The Icon Language
The Language of Graphical Execution Plans in Microsoft SQL Server 2008 R2
Clustered Index Scan
Clustered Index Seek
Non-Clustered Index Scan
Non-Clustered Index Seek
Key Lookup
Table Scan
RID LookUp
Hash Match
Nested Loops
Merge Join
Sort
Filter
16