Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Reading Execution Plans for Performance Tuning
Thomas LeBlanc
Independent SQL Server/BI Consultant
• About Me… Independent Consultant DW/BI Architect Database Normalization “Nut”
Crazy about Dimensions
Retired Developer TheSmilingDBA – twitter, blog & gmail PASS volunteer - Chair of Excel BI VC
Thomas LeBlanc
My Assumptions About You • Some development of database applications
• Curious About Performance Tuning
• Sense of Humor
• Want Some Answers To Query Questions
What Are We Talking About
• Execution Plan Basic Terminology
• History
• Demo, Demo and More Demos…
• Additional Help With Query Plans
Terminology • Query Plan – Used by the Optimizer
– Many useful articles
– Estimated versus Actual
• Scans – Table for Heap
– Clustered Index Scan
– Non-Clustered Scan
• Seek – Good use of index to find data
Terminology - Continued • Loops
– Nested Join • Each row in outer set joins to matches in inner set
• Best with small data sets
– Merge Join • Rows in outer and inner sets are ordered the same
• Rows are merged together like a zipper
– Hash Join • Not necessarily bad, but most expensive
• Join column is hashed and resulting hash and columns are put into hash table to join sets together
Terminology - Continued
• Lookup – After Seek, more data is located
– RID versus Key Lookup • RID – table has no clustered index (Heap)
• Key – table has a clustered index
• Other Operators – Sort from order by clause
– Aggregate from Group By and Sum/Count/Min/Max
– Parallelism from Cost above Threshold
History • Text
– Enterprise Manager (not Management Studio)
– SET_SHOWPLAN_TEXT ON (demo)
• Graphical – Started in Management Studio (SSMS) 2005
• Missing Index – Included in SSMS in 2008
• Warnings and Memory Grants – 2012
• Operator Cost – 2014
• Let’s look at some demos!!!
Demo
• History
Next Demos
• Table Scan
• Clustered Index Scan
• Non-Clustered Index Scan with Key Lookup
• Covering Index
• Index Seek
Demo
• Scans and Seeks
Next Demos
• Nested Loop – Fastest and most common
• Merge Loop – Merge to sorted record sets
• Hash Loop – Smaller table made into Hash Table
– Larger table (set) looped though searching for Hash value in Hash Table for matches
Demo
• Loops
Next Demos
• Compute Scaler – Concatenates Last and First Names
• Sorts – ORDER BY or DISTINCT or GROUP BY
• Aggregates
• Properties – more information
• Insert and Updates (Deletes)
Demo
• Other Iterators
Parallelism
• Using Multiple Processors
• MAXDOP Configuration – Set to 0 (all) by Default
• Cost Threshold
– Defaults to 5
– Reduce to get more parallelism
Demo
• Parallelism
Thanks Thomas LeBlanc
Twitter @TheSmilingDBA [email protected] [email protected]