SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
DISCOVERING   Jason Strate
                 Database Architect


THE PLAN CACHE   Pragmatic Works, Inc.
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

Mais conteúdo relacionado

Mais procurados

Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...Chester Chen
 
Why & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to queryWhy & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to queryAntonios Chatzipavlis
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLMichael Rys
 
Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBAKaran Kukreja
 
U-SQL Query Execution and Performance Basics (SQLBits 2016)
U-SQL Query Execution and Performance Basics (SQLBits 2016)U-SQL Query Execution and Performance Basics (SQLBits 2016)
U-SQL Query Execution and Performance Basics (SQLBits 2016)Michael Rys
 
Stored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlStored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlnishantdavid9
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Michael Rys
 
Static analysis of java enterprise applications
Static analysis of java enterprise applicationsStatic analysis of java enterprise applications
Static analysis of java enterprise applicationsAnastasiοs Antoniadis
 
Streaming Inference with Apache Beam and TFX
Streaming Inference with Apache Beam and TFXStreaming Inference with Apache Beam and TFX
Streaming Inference with Apache Beam and TFXDatabricks
 

Mais procurados (9)

Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
Analytics Metrics delivery and ML Feature visualization: Evolution of Data Pl...
 
Why & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to queryWhy & how to optimize sql server for performance from design to query
Why & how to optimize sql server for performance from design to query
 
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQLTaming the Data Science Monster with A New ‘Sword’ – U-SQL
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
 
Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBA
 
U-SQL Query Execution and Performance Basics (SQLBits 2016)
U-SQL Query Execution and Performance Basics (SQLBits 2016)U-SQL Query Execution and Performance Basics (SQLBits 2016)
U-SQL Query Execution and Performance Basics (SQLBits 2016)
 
Stored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlStored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sql
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
 
Static analysis of java enterprise applications
Static analysis of java enterprise applicationsStatic analysis of java enterprise applications
Static analysis of java enterprise applications
 
Streaming Inference with Apache Beam and TFX
Streaming Inference with Apache Beam and TFXStreaming Inference with Apache Beam and TFX
Streaming Inference with Apache Beam and TFX
 

Semelhante a Discovering the Plan Cache (#SQLSat 206)

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
 
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
 
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
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Finaljucaab
 
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
 
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
 
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.
 
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
 
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
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04Carlos Sierra
 
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
 
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
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Lucas Jellema
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...HostedbyConfluent
 
In-memory ColumnStore Index
In-memory ColumnStore IndexIn-memory ColumnStore Index
In-memory ColumnStore IndexSolidQ
 

Semelhante a Discovering the Plan Cache (#SQLSat 206) (20)

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...
 
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
 
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
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Final
 
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
 
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
 
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
 
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
 
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
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04
 
Taming the shrew Power BI
Taming the shrew Power BITaming the shrew Power BI
Taming the shrew Power BI
 
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
 
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
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
 
In-memory ColumnStore Index
In-memory ColumnStore IndexIn-memory ColumnStore Index
In-memory ColumnStore Index
 

Mais de 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
 

Mais de 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
 

Último

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Último (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Discovering the Plan Cache (#SQLSat 206)

  • 1. DISCOVERING Jason Strate Database Architect THE PLAN CACHE Pragmatic Works, Inc.
  • 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