SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
DISCOVERING
THE PLAN CACHE        Jason Strate
                      Database Architect
                      Pragmatic Works, Inc.

   SQL SATURDAY 211
            CHICAGO
SESSION AGENDA


Session Goals

Viewing The Plan Cache

Showplan XML Structure

Scenarios and Demos

Wrap Up
SESSION GOALS


          Viewing    Showplan    Scenarios
Session
          The Plan     XML         and       Wrap Up
 Goals
           Cache     Structure    Demos
SESSION GOALS

1. Discuss the plan cache
2. Explore the plan cache
3. Demonstrate methods
   to query plan cache
4. Demonstrate
   performance tuning
   concepts
CONTENT COMPATIBILIT Y


 SQL Server
   2012


 SQL Server
 2008 (R2)


 SQL Server
   2005
VIEWING THE PLAN
                    CACHE

          Viewing    Showplan    Scenarios
Session
          The Plan     XML         and       Wrap Up
 Goals
           Cache     Structure    Demos
PLAN CACHE

Portion of SQL Server memory that stores execution plans
that have been prepared by the Query Optimizer. Execution
plans are used to by SQL Server to execute SQL statements.
PLAN CACHE

Portion of SQL Server memory that stores execution plans
that have been prepared by the Query Optimizer. Execution
plans are used to by SQL Server to execute SQL statements.


          Pros                          Cons
         No setup                  Reset with service
        Query-able                    Activity flush
        Actionable                 Plans miss cache
        Real World                       In Use
PLAN CACHE


  sys.dm_exec_cached_plans
• All Plans
• Size
• Use count
  sys.dm_exec_query_plan
   (plan_handle)
• Table Valued Function
• SHOWPLAN XML as XML
  sys.dm_exec_text_query_plan
   (plan_handle,0,-1)
• Table Valued Function
• SHOWPLAN XML as text
PLAN HANDLE

0x06000F001CF36A2640C1318A…
 Varbinary(64)
 Hash value
 Identifies plan
WHERE IN THE WORLD IS PLAN_HANDLE?

sys.dm_exec_requests
  Current connection
  Vaguely similar to sp_who
sys.dm_exec_query_stats
  Stats on executed queries
  Contains SQL_Handle
sys.dm_exec_cached_plans
  Stats on cached plans
  Distinct list of plans

                               http://www.flickr.com/photos/fallentomato/3918329246/
SHOWPLAN XML
                  STRUCTURE

          Viewing    Showplan    Scenarios
Session
          The Plan     XML         and       Wrap Up
 Goals
           Cache     Structure    Demos
GETTING STARTED




      DBA-409-S
GETTING STARTED




      DBA-409-S
GETTING STARTED




      DBA-409-S
GETTING STARTED




      DBA-409-S
EXECUTION PLAN




      DBA-409-S
SHOWPLAN XML STRUCTURE




          DBA-409-S
SHOWPLAN XML STRUCTURE

What is in it?
  ShowPlanXML

    BatchSequence

      Batch

       Statements

         StmtSimple
                      http://www.flickr.com/photos/etringita/854298772/
GOING BELOW STMTSIMPLE



Missing          Parameter      Warnings          RelOp
Indexes          List           •Plan Affecting   •EstimateRows,
•Indexes that    •Parameters     Convert           EstimateIO,
 would improve    passed into   •Columns with      PhysicalOp,
 plan             query          no Statistics    •Hash,
 performance                    •Unmatched         IndexScan,
                                 Indexes           NestedLoops
                                                  •OutputList
CAUTION



      Volatile   Cache
       Data      In Use


       Use         Be
      Xquery     Mindful
XQUERY FUNCTIONS

• Forward slashes
   / means to find the specific location
   // means find any from the current location
• Important Functions
   • nodes()
   • value()
   • exist()
   • query()
• Everything is case sensitive
SCENARIOS AND DEMOS


           Viewing    Showplan    Scenarios
 Session
           The Plan     XML         and       Wrap Up
  Goals
            Cache     Structure    Demos
MISSING INDEXES

What plans would benefit from indexes?
  DMVs
    sys.dm_db_missing_index_columns
    sys.dm_db_missing_index_details
    sys.dm_db_missing_index_group_stats
    sys.dm_db_missing_index_groups




                            DBA-409-S
MISSING INDEXES

What plans would benefit from indexes?
  DMVs
    sys.dm_db_missing_index_columns
    sys.dm_db_missing_index_details
    sys.dm_db_missing_index_group_stats
    sys.dm_db_missing_index_groups




                What Queries
                Should I Test?
                                 http://www.flickr.com/photos/fallentomato/3918329246/
MISSING INDEXES   Demo 1
CONVERSION WARNINGS

Data types matter?       Here lies your
  varchar vs. nvarchar    transaction
  scan vs. seek


What plans have this issue?
OTHER WARNINGS




Columns         Unmatched      Spill to
 with no         Indexes      Tempdb*
Statistics
IMPLICIT CONVERSIONS   Demo 2
 AND OTHER WARNINGS
POOR PARAMETER SNIFFING

Think about the plans you
 find example…
   What has changed in the
    environments?
   Is the plan using the wrong
    values?


What parameters is the
plan using?
PARAMETER    Demo 3

  SNIFFING
STATEMENT INFORMATION

What’s the parallelism trigger?
• Parallelism is cost based
• Query cost default 5
QUERY TREE ESTIMATES

What does SQL Server expect?
• CPU
• IO
• Rows
• Cost
QUERY PROPERTIES   Demo 3
LET’S GET PHYSICAL
PHYSICAL OPERATIONS   Demo 5
INDEX OPERATIONS

 Access Methods:Full Scans/sec
INDEX OPERATIONS

 Access Methods:Full Scans/sec
INDEX OPERATIONS

What about large tables?
   Scans?
    Good?
    Bad?


What do you do when you
see large counts of scans
on an index?
INDEX OPERATIONS

What plans are using that index?
  Should you drop it?
  What is the potential effect?




                                   http://www.flickr.com/photos/s3a/4436302537/
INDEX OPERATIONS   Demo 5
KEY LOOKUP

Find value in one index
Look up more columns in clustered index
DEEPER FOR INCLUDED INDEXES

You found them…
     NOW fix them…

The information is in the plan!
• Investigate the nodes
• Pull in the data!
KEY LOOKUPS &   Demo 4
INCLUDED COLUMNS
WRAP UP


          Viewing    Showplan    Scenarios
Session
          The Plan     XML         and       Wrap Up
 Goals
           Cache     Structure    Demos
FIND YOUR OWN TREASURE

 http://schemas.microsoft.com/sqlserver
  /2004/07/showplan/showplanxml.xsd
SUMMARY

1. Plan Cache IS your
   performance work load
2. Information is readily
   available
3. Techniques to access
   not as complex as
   appearances
4. Scale your performance
   knowledge across the
   environment
SQL SERVER MVP DEEP DIVES, VOLUME 2




                  www.operationsmile.org
                  www.manning.com/delaney
RESOURCES

Jason      e: jstrate@pragmaticworks.com
Strate
           e: jasonstrate@gmail.com
           b: www.jasonstrate.com
           t: StrateSQL
Resources jasonstrate.com/go/Cache2013

Weitere ähnliche Inhalte

Ähnlich wie Discovering the plan cache (#SQLSat211)

An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1Navneet Upneja
 
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...Databricks
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersMichael Rys
 
1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part isqlserver.co.il
 
Migrating on premises workload to azure sql database
Migrating on premises workload to azure sql databaseMigrating on premises workload to azure sql database
Migrating on premises workload to azure sql databasePARIKSHIT SAVJANI
 
The Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL ServerThe Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL ServerJason Strate
 
Sf big analytics_2018_04_18: Evolution of the GoPro's data platform
Sf big analytics_2018_04_18: Evolution of the GoPro's data platformSf big analytics_2018_04_18: Evolution of the GoPro's data platform
Sf big analytics_2018_04_18: Evolution of the GoPro's data platformChester Chen
 
Spark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.comSpark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.comSyed Hadoop
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDAGEOP LTD
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Finaljucaab
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsTeamstudio
 
Jss 2015 in memory and operational analytics
Jss 2015   in memory and operational analyticsJss 2015   in memory and operational analytics
Jss 2015 in memory and operational analyticsDavid Barbarin
 
[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analytics[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analyticsGUSS
 
In-memory ColumnStore Index
In-memory ColumnStore IndexIn-memory ColumnStore Index
In-memory ColumnStore IndexSolidQ
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsZohar Elkayam
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04Carlos Sierra
 
Understanding the SQL aspects of Spark - Spark SQL.pptx
Understanding the SQL aspects of Spark - Spark SQL.pptxUnderstanding the SQL aspects of Spark - Spark SQL.pptx
Understanding the SQL aspects of Spark - Spark SQL.pptxKnoldus Inc.
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 

Ähnlich wie Discovering the plan cache (#SQLSat211) (20)

An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1
 
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
 
U-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for DevelopersU-SQL - Azure Data Lake Analytics for Developers
U-SQL - Azure Data Lake Analytics for Developers
 
1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part i
 
Migrating on premises workload to azure sql database
Migrating on premises workload to azure sql databaseMigrating on premises workload to azure sql database
Migrating on premises workload to azure sql database
 
The Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL ServerThe Plan Cache Whisperer - Performance Tuning SQL Server
The Plan Cache Whisperer - Performance Tuning SQL Server
 
Sf big analytics_2018_04_18: Evolution of the GoPro's data platform
Sf big analytics_2018_04_18: Evolution of the GoPro's data platformSf big analytics_2018_04_18: Evolution of the GoPro's data platform
Sf big analytics_2018_04_18: Evolution of the GoPro's data platform
 
Spark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.comSpark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.com
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance Analysis
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Final
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational Controls
 
Jss 2015 in memory and operational analytics
Jss 2015   in memory and operational analyticsJss 2015   in memory and operational analytics
Jss 2015 in memory and operational analytics
 
[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analytics[JSS2015] In memory and operational analytics
[JSS2015] In memory and operational analytics
 
In-memory ColumnStore Index
In-memory ColumnStore IndexIn-memory ColumnStore Index
In-memory ColumnStore Index
 
Taming the shrew Power BI
Taming the shrew Power BITaming the shrew Power BI
Taming the shrew Power BI
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04
 
Understanding the SQL aspects of Spark - Spark SQL.pptx
Understanding the SQL aspects of Spark - Spark SQL.pptxUnderstanding the SQL aspects of Spark - Spark SQL.pptx
Understanding the SQL aspects of Spark - Spark SQL.pptx
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
 

Mehr von Jason Strate

Accelerating Business Intelligence Solutions with Microsoft Azure pass
Accelerating Business Intelligence Solutions with Microsoft Azure   passAccelerating Business Intelligence Solutions with Microsoft Azure   pass
Accelerating Business Intelligence Solutions with Microsoft Azure passJason Strate
 
Strategies for SQL Server Index Analysis
Strategies for SQL Server Index AnalysisStrategies for SQL Server Index Analysis
Strategies for SQL Server Index AnalysisJason Strate
 
Leveraging Cloud for the Modern SQL Developer
Leveraging Cloud for the Modern SQL DeveloperLeveraging Cloud for the Modern SQL Developer
Leveraging Cloud for the Modern SQL DeveloperJason Strate
 
Getting Started with Windows Azure and SQL Databases
Getting Started with Windows Azure and SQL DatabasesGetting Started with Windows Azure and SQL Databases
Getting Started with Windows Azure and SQL DatabasesJason Strate
 
5 SQL Server Indexing Myths
5 SQL Server Indexing Myths5 SQL Server Indexing Myths
5 SQL Server Indexing MythsJason Strate
 
Introduction to Columnstore Indexes
Introduction to Columnstore IndexesIntroduction to Columnstore Indexes
Introduction to Columnstore IndexesJason Strate
 
Introduction to Clustered Indexes and Heaps
Introduction to Clustered Indexes and HeapsIntroduction to Clustered Indexes and Heaps
Introduction to Clustered Indexes and HeapsJason Strate
 
The Flavors of Non-Clustered Indexes
The Flavors of Non-Clustered IndexesThe Flavors of Non-Clustered Indexes
The Flavors of Non-Clustered IndexesJason Strate
 
Necessary Evils, Building Optimized CRUD Procedures
Necessary Evils, Building Optimized CRUD ProceduresNecessary Evils, Building Optimized CRUD Procedures
Necessary Evils, Building Optimized CRUD ProceduresJason Strate
 
How Do Non-Clustered Indexes Improve Performance?
How Do Non-Clustered Indexes Improve Performance?How Do Non-Clustered Indexes Improve Performance?
How Do Non-Clustered Indexes Improve Performance?Jason Strate
 
Choosing Your Clustered Index
Choosing Your Clustered IndexChoosing Your Clustered Index
Choosing Your Clustered IndexJason Strate
 
BuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended EventsBuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended EventsJason Strate
 
5 Amazing Reasons DBAs Need to Love Extended Events
5 Amazing Reasons DBAs Need to Love Extended Events5 Amazing Reasons DBAs Need to Love Extended Events
5 Amazing Reasons DBAs Need to Love Extended EventsJason Strate
 
5 ways to improve performance through indexing
5 ways to improve performance through indexing5 ways to improve performance through indexing
5 ways to improve performance through indexingJason Strate
 
The Side Effect of NOLOCK
The Side Effect of NOLOCKThe Side Effect of NOLOCK
The Side Effect of NOLOCKJason Strate
 
Introduction to SQL Server Security
Introduction to SQL Server SecurityIntroduction to SQL Server Security
Introduction to SQL Server SecurityJason Strate
 
What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)Jason Strate
 
A Function by Any Other Name is a Function
A Function by Any Other Name is a FunctionA Function by Any Other Name is a Function
A Function by Any Other Name is a FunctionJason Strate
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting forJason Strate
 

Mehr von Jason Strate (19)

Accelerating Business Intelligence Solutions with Microsoft Azure pass
Accelerating Business Intelligence Solutions with Microsoft Azure   passAccelerating Business Intelligence Solutions with Microsoft Azure   pass
Accelerating Business Intelligence Solutions with Microsoft Azure pass
 
Strategies for SQL Server Index Analysis
Strategies for SQL Server Index AnalysisStrategies for SQL Server Index Analysis
Strategies for SQL Server Index Analysis
 
Leveraging Cloud for the Modern SQL Developer
Leveraging Cloud for the Modern SQL DeveloperLeveraging Cloud for the Modern SQL Developer
Leveraging Cloud for the Modern SQL Developer
 
Getting Started with Windows Azure and SQL Databases
Getting Started with Windows Azure and SQL DatabasesGetting Started with Windows Azure and SQL Databases
Getting Started with Windows Azure and SQL Databases
 
5 SQL Server Indexing Myths
5 SQL Server Indexing Myths5 SQL Server Indexing Myths
5 SQL Server Indexing Myths
 
Introduction to Columnstore Indexes
Introduction to Columnstore IndexesIntroduction to Columnstore Indexes
Introduction to Columnstore Indexes
 
Introduction to Clustered Indexes and Heaps
Introduction to Clustered Indexes and HeapsIntroduction to Clustered Indexes and Heaps
Introduction to Clustered Indexes and Heaps
 
The Flavors of Non-Clustered Indexes
The Flavors of Non-Clustered IndexesThe Flavors of Non-Clustered Indexes
The Flavors of Non-Clustered Indexes
 
Necessary Evils, Building Optimized CRUD Procedures
Necessary Evils, Building Optimized CRUD ProceduresNecessary Evils, Building Optimized CRUD Procedures
Necessary Evils, Building Optimized CRUD Procedures
 
How Do Non-Clustered Indexes Improve Performance?
How Do Non-Clustered Indexes Improve Performance?How Do Non-Clustered Indexes Improve Performance?
How Do Non-Clustered Indexes Improve Performance?
 
Choosing Your Clustered Index
Choosing Your Clustered IndexChoosing Your Clustered Index
Choosing Your Clustered Index
 
BuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended EventsBuildingSecurity Audits with Extended Events
BuildingSecurity Audits with Extended Events
 
5 Amazing Reasons DBAs Need to Love Extended Events
5 Amazing Reasons DBAs Need to Love Extended Events5 Amazing Reasons DBAs Need to Love Extended Events
5 Amazing Reasons DBAs Need to Love Extended Events
 
5 ways to improve performance through indexing
5 ways to improve performance through indexing5 ways to improve performance through indexing
5 ways to improve performance through indexing
 
The Side Effect of NOLOCK
The Side Effect of NOLOCKThe Side Effect of NOLOCK
The Side Effect of NOLOCK
 
Introduction to SQL Server Security
Introduction to SQL Server SecurityIntroduction to SQL Server Security
Introduction to SQL Server Security
 
What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)
 
A Function by Any Other Name is a Function
A Function by Any Other Name is a FunctionA Function by Any Other Name is a Function
A Function by Any Other Name is a Function
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
 

Discovering the plan cache (#SQLSat211)

  • 1. DISCOVERING THE PLAN CACHE Jason Strate Database Architect Pragmatic Works, Inc. SQL SATURDAY 211 CHICAGO
  • 2. SESSION AGENDA Session Goals Viewing The Plan Cache Showplan XML Structure Scenarios and Demos Wrap Up
  • 3. SESSION GOALS Viewing Showplan Scenarios Session The Plan XML and Wrap Up Goals Cache Structure Demos
  • 4. SESSION GOALS 1. Discuss the plan cache 2. Explore the plan cache 3. Demonstrate methods to query plan cache 4. Demonstrate performance tuning concepts
  • 5. CONTENT COMPATIBILIT Y SQL Server 2012 SQL Server 2008 (R2) SQL Server 2005
  • 6. VIEWING THE PLAN CACHE Viewing Showplan Scenarios Session The Plan XML and Wrap Up Goals Cache Structure Demos
  • 7. PLAN CACHE Portion of SQL Server memory that stores execution plans that have been prepared by the Query Optimizer. Execution plans are used to by SQL Server to execute SQL statements.
  • 8. PLAN CACHE Portion of SQL Server memory that stores execution plans that have been prepared by the Query Optimizer. Execution plans are used to by SQL Server to execute SQL statements. Pros Cons No setup Reset with service Query-able Activity flush Actionable Plans miss cache Real World In Use
  • 9. PLAN CACHE  sys.dm_exec_cached_plans • All Plans • Size • Use count  sys.dm_exec_query_plan (plan_handle) • Table Valued Function • SHOWPLAN XML as XML  sys.dm_exec_text_query_plan (plan_handle,0,-1) • Table Valued Function • SHOWPLAN XML as text
  • 11. WHERE IN THE WORLD IS PLAN_HANDLE? sys.dm_exec_requests  Current connection  Vaguely similar to sp_who sys.dm_exec_query_stats  Stats on executed queries  Contains SQL_Handle sys.dm_exec_cached_plans  Stats on cached plans  Distinct list of plans http://www.flickr.com/photos/fallentomato/3918329246/
  • 12. SHOWPLAN XML STRUCTURE Viewing Showplan Scenarios Session The Plan XML and Wrap Up Goals Cache Structure Demos
  • 13. GETTING STARTED DBA-409-S
  • 14. GETTING STARTED DBA-409-S
  • 15. GETTING STARTED DBA-409-S
  • 16. GETTING STARTED DBA-409-S
  • 17. EXECUTION PLAN DBA-409-S
  • 19. SHOWPLAN XML STRUCTURE What is in it? ShowPlanXML BatchSequence Batch Statements StmtSimple http://www.flickr.com/photos/etringita/854298772/
  • 20. GOING BELOW STMTSIMPLE Missing Parameter Warnings RelOp Indexes List •Plan Affecting •EstimateRows, •Indexes that •Parameters Convert EstimateIO, would improve passed into •Columns with PhysicalOp, plan query no Statistics •Hash, performance •Unmatched IndexScan, Indexes NestedLoops •OutputList
  • 21. CAUTION Volatile Cache Data In Use Use Be Xquery Mindful
  • 22. XQUERY FUNCTIONS • Forward slashes  / means to find the specific location  // means find any from the current location • Important Functions • nodes() • value() • exist() • query() • Everything is case sensitive
  • 23. SCENARIOS AND DEMOS Viewing Showplan Scenarios Session The Plan XML and Wrap Up Goals Cache Structure Demos
  • 24. MISSING INDEXES What plans would benefit from indexes?  DMVs  sys.dm_db_missing_index_columns  sys.dm_db_missing_index_details  sys.dm_db_missing_index_group_stats  sys.dm_db_missing_index_groups DBA-409-S
  • 25. MISSING INDEXES What plans would benefit from indexes?  DMVs  sys.dm_db_missing_index_columns  sys.dm_db_missing_index_details  sys.dm_db_missing_index_group_stats  sys.dm_db_missing_index_groups What Queries Should I Test? http://www.flickr.com/photos/fallentomato/3918329246/
  • 26. MISSING INDEXES Demo 1
  • 27. CONVERSION WARNINGS Data types matter? Here lies your  varchar vs. nvarchar transaction  scan vs. seek What plans have this issue?
  • 28. OTHER WARNINGS Columns Unmatched Spill to with no Indexes Tempdb* Statistics
  • 29. IMPLICIT CONVERSIONS Demo 2 AND OTHER WARNINGS
  • 30. POOR PARAMETER SNIFFING Think about the plans you find example…  What has changed in the environments?  Is the plan using the wrong values? What parameters is the plan using?
  • 31. PARAMETER Demo 3 SNIFFING
  • 32. STATEMENT INFORMATION What’s the parallelism trigger? • Parallelism is cost based • Query cost default 5
  • 33. QUERY TREE ESTIMATES What does SQL Server expect? • CPU • IO • Rows • Cost
  • 37. INDEX OPERATIONS  Access Methods:Full Scans/sec
  • 38. INDEX OPERATIONS  Access Methods:Full Scans/sec
  • 39. INDEX OPERATIONS What about large tables?  Scans?  Good?  Bad? What do you do when you see large counts of scans on an index?
  • 40. INDEX OPERATIONS What plans are using that index?  Should you drop it?  What is the potential effect? http://www.flickr.com/photos/s3a/4436302537/
  • 42. KEY LOOKUP Find value in one index Look up more columns in clustered index
  • 43. DEEPER FOR INCLUDED INDEXES You found them… NOW fix them… The information is in the plan! • Investigate the nodes • Pull in the data!
  • 44. KEY LOOKUPS & Demo 4 INCLUDED COLUMNS
  • 45. WRAP UP Viewing Showplan Scenarios Session The Plan XML and Wrap Up Goals Cache Structure Demos
  • 46. FIND YOUR OWN TREASURE  http://schemas.microsoft.com/sqlserver  /2004/07/showplan/showplanxml.xsd
  • 47. SUMMARY 1. Plan Cache IS your performance work load 2. Information is readily available 3. Techniques to access not as complex as appearances 4. Scale your performance knowledge across the environment
  • 48. SQL SERVER MVP DEEP DIVES, VOLUME 2  www.operationsmile.org  www.manning.com/delaney
  • 49. RESOURCES Jason e: jstrate@pragmaticworks.com Strate e: jasonstrate@gmail.com b: www.jasonstrate.com t: StrateSQL Resources jasonstrate.com/go/Cache2013