SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
Presented to the
San Francisco SQL Server User Group
        www.bayareasql.org
           March 11, 2009

         Brad M McGehee
       Microsoft SQL Server MVP
       Director of DBA Education
           Red Gate Software
      bradmcgehee@hotmail.com
You are a SQL Server DBA or developer with
 novice to intermediate knowledge of SQL Server.
 You have a basic understanding of indexing and
 Transact-SQL.
 You want to learn the basics of how to read and
 interpret Execution Plans so that you can better
 understand how your queries are executing, and
 so that you can better figure out ways to
 optimize them.
 The difference between a run-of-the-mill DBA/Developer from an exceptional DBA/Developer is that the
exceptional DBA/Developer thoroughly understands how to use their available tools to their full potential.
A execution plan, simply put, describes the data
retrieval/storage methods chosen by the Query
Optimizer to execute a specific query.
So why is this important to know?
If you understand how a query was executed by
SQL Server, you have the information you need to
help you to figure out ways to potentially
optimize it.
T-SQL is sent to the relational engine.
T-SQL is parsed to check to see if it is written correctly.
T-SQL is next run through the algebrizer, which resolves all the names
of the various objects, tables and columns.
Algebrizer output is sent to Query Optimizer.
Then:
  Trivial plan may be generated.
  Otherwise, cost-based calculations are performed to identify the best way to execute the
  query. In other words, an execution plan is created.
Index and column statistics are used during above cost-based
calculations to help the query optimizer determine the best execution
plan. The better the statistics, the better the execution plan.
Note: DDL T-SQL is not optimized, only DML T-SQL
The creation of an execution plan takes time.
Not every execution option is always explored, a “good
enough” execution plan is often generated, then sent to the
database engine for execution.
The execution plan is estimated, and may change when the
T-SQL is actually executed by the database engine.
Execution plans are usually cached (in the plan cache) for
later use so that it can be reused if an identical (or
paramerized) query is submitted for execution again.
Reusing a cached execution plan can save time because a
new execution plan does not have to be recreated each
time the same query is re-executed.
Text (Deprecated)
  Harder for many people to read
XML (Storage Format)
  XML code is not really designed to be read directly by
  DBAs
  Can be saved and shared with others (portable)
  Can be displayed in graphical format (main use)
Graphical (Display Format)
  Generally easier to read and understand by beginners
  Is produced from XML execution plan
  Our focus today
Demo
Estimated
  Produced without running the query.
  Displays estimated data only.
  Can save time and resources.
  Can’t be used if the query creates object it needs to use: i.e.
  temp table.
  Not aways accurate, can be misleading, especially if data is
  skewed, or the statistics are outdated, or if parallelism is
  involved.
Actual
  Produced after a query actually runs, may or may not be same as
  estimated execution plan.
  Displays estimated and actual results.
Demo
SSMS (our choice for today)
SET commands (some shown in previous demo)
Profiler (Showplan XML Event, shows estimated
plan)
SQL Server 2005 Performance Dashboard
SQL Server 2008 Data Collector
Demo
 Overview of Graphical Execution Plan Screen
 Using the Zoom Button (Around, In, Out, Fit)
 Learning to Read from Right to Left and Top to Bottom
 Learning about Icons (operators)
 Learning about costs (per operator)
 Learning about Tool Tips (and Properties)
 Learning about Arrows
 Executing Multiple Queries
Each operator implements a single basic
operation, such as:
  Scanning data from a table
  Seeking data in a table
  Aggregating data
  Sorting
  Joining two data sets
  Etc.
In total, there are 79 different operator that can
be included in an execution plan.
Logical and physical operators
Logical and physical operators
There are 79 Graphical Execution Plan icons.
SELECT
Table Scan
Clustered Index Scan
Clustered Index Seek
Non-Clustered Scan
Non-Clustered Index Seek
RID Lookup
Key Lookup
Sort
Joins (loop, merge, hash)
Parallelism (special case)
Represents the end results of a SELECT query.
Good place to start when evaluating any
execution plan.
To optimize performance, the number of rows
that are returned should be the minimum
number of rows necessary to meet the needs of
the query.
Similar icons are available for INSERT, UPDATE,
and DELETE.
Seeing a table scan often indicates a problem that needs to be
addressed.
A table scan indicates that every row in the table had to be examined
to see if it met the query criteria, which can mean slow performance if
there are a large numbers of rows.
A table scan indicates there is no clustered index on the table, and the
table is a heap.
In most cases, you will want to add a clustered index to every table, as
it has the potential of boosting the performance of the query, even if a
clustered index scan is conducted.
This is because leaf nodes of the clustered index are stored together
(logically, and hopefully physically). In a heap, they are not, which can
hurt performance.
A clustered index scan is a scan of all the rows of
a table that has a clustered index.
Like a table scan, clustered index scans can be
slow and use up lots of server resources.
Generally, clustered index scans should generally
be avoided (but better than table scans).
On the other hand, when tables are small or
many rows are returned, then a clustered index
scan might be the fastest way to return data.
If there is an available and useful index, and there
is a sargeable WHERE clause, the query optimizer
can usually, very quickly, identify the rows to be
returned and return them without having to scan
each row of the table.
Ideally, for best query performance, clustered
index seeks should be as used often as feasible.
Consider them the “golden standard” for
returning data.
Of course, there are exceptions, as we will see in
the demo.
All records in the table are scanned, and all rows
that match the WHERE clause are returned.
As with all scans, it can be slow and require extra
I/O resources.
Generally, non-clustered index scans should be
avoided.
A non-clustered index is used to identify the row(s)
to be returned, so every row does not need to be
scanned (assumes sargeable WHERE clause).
This is generally much faster than a non-clustered
index scan.
Like clustered index seeks, non-clustered index
seeks are generally a good thing.
One exception is if bookmark (RID or Key) lookups
occur as part of the non-clustered index seek, then
performance may lag if many rows are returned.
A RID Lookup is generally an indicator of a
performance issue.
A RID Lookup is a form of a bookmark index lookup
on a table without a clustered index (a heap).
While RID Lookups are often faster than most
“scans,” this is often not the case if many rows have
to be returned.
Generally, RID Lookups should be eliminated with
the addition of an appropriate clustered index, and if
necessary, a covering or included index.
A key lookup is often an indicator of potentially less
than optimal performance.
A key lookup is a bookmark lookup on a table with a
clustered index.
A key lookup is generally faster than a RID lookup.
While key lookups are often faster than most
“scans,” this is not always the case, especially if a lot
of data needs to be returned.
Often, key lookups should be eliminated with the
addition of a covering or included index.
Sorts occur when you specify that returned data
be ordered.
Sorts may also occur even if you don’t use the
ORDER clause.
Sorts are normal and aren’t generally a problem.
But if you return too much data, then sorts may
take a lot of resources (including tempdb), and
you should identify ways of reducing the number
of rows returned.
Loop: For each row in the top (outer) input, scan the bottom
   (inner) input, and output matching rows.

   Merge: Match rows from two suitably sorted input tables
   exploiting their sort order.

   Hash: Use each row from the top input (table) to build a hash
   table, and each row from the bottom input (table) to probe into
   the hash table, outputting all matching rows.

More on next page
There is no “ideal join,” it all depends on the data being
joined.
A join can occur in an execution plan even if there is no JOIN
statement in a query.
From a resource perspective, a nested loop join uses fewer
resources, and seeing one generally is a good indicator of
good overall performance. Often best for smaller joins.
Merge and hash joints use more resources and may be an
indicator that too much data is being returned.
Demo
Parallelism is used to take a query, break it into two or more
parts, execute it in parallel, then recombine the parts.
  Distribute Stream: Takes a single input stream and produces multiple output
  streams.
  Gather Stream: Consumes multiple input streams and produces a single
  output stream by combining the input streams.
  Repartition Stream: Consumes multiple streams and produces multiple
  streams of records.
  Bitmap Create: Bitmap filtering speeds up query execution by eliminating
  rows with key values that cannot produce any join records before passing rows
  through another operator.
Parallelism may or may not boost query performance.

                      Note: The two arrows in a regular icon indicate
                      parallelism was used for that operator
This is just a small sample of the things you can do with
Graphical Execution Plans.
The learning curve for learning about Graphical Execution
Plans is high, but worth the effort.
Graphical Execution Plans are a powerful tool to help DBAs
understand how a query executes.
Based on the information provided by an execution plan, and
the DBA’s knowledge of SQL Server, many queries (and
indexes) can often be optimized.
Please ask questions loud enough for everyone
to hear.
Free E-Books:
  www.sqlservercentral.com/Books

Check these out:
  SQL Server 2005/2008 Books Online (of course)
  www.SQLServerCentral.com
  www.Simple-Talk.com
  www.SQL-Server-Performance.Com

Contact me at:
bradmcgehee@hotmail.com

Blogs:
www.simple-talk.com/community/blogs/brad_mcgehee/default.aspx
http://www.sqlservercentral.com/blogs/aloha_dba/default.aspx
http://twitter.com/bradmcgehee

Weitere ähnliche Inhalte

Was ist angesagt?

Data all over the place! How SQL and Apache Calcite bring sanity to streaming...
Data all over the place! How SQL and Apache Calcite bring sanity to streaming...Data all over the place! How SQL and Apache Calcite bring sanity to streaming...
Data all over the place! How SQL and Apache Calcite bring sanity to streaming...Julian Hyde
 
Introduction to Databases - query optimizations for MySQL
Introduction to Databases - query optimizations for MySQLIntroduction to Databases - query optimizations for MySQL
Introduction to Databases - query optimizations for MySQLMárton Kodok
 
How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...DataWorks Summit/Hadoop Summit
 
Cost-based Query Optimization in Apache Phoenix using Apache Calcite
Cost-based Query Optimization in Apache Phoenix using Apache CalciteCost-based Query Optimization in Apache Phoenix using Apache Calcite
Cost-based Query Optimization in Apache Phoenix using Apache CalciteJulian Hyde
 
Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Stéphane Fréchette
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...
R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...
R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...Edureka!
 
Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsAsanka Dilruk
 
U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)Michael Rys
 
Hyperion essbase basics
Hyperion essbase basicsHyperion essbase basics
Hyperion essbase basicsAmit Sharma
 
Power of SPL Breakout Session
Power of SPL Breakout SessionPower of SPL Breakout Session
Power of SPL Breakout SessionSplunk
 
U-SQL Partitioned Data and Tables (SQLBits 2016)
U-SQL Partitioned Data and Tables (SQLBits 2016)U-SQL Partitioned Data and Tables (SQLBits 2016)
U-SQL Partitioned Data and Tables (SQLBits 2016)Michael Rys
 
See sql server graphical execution plans in action tech republic
See sql server graphical execution plans in action   tech republicSee sql server graphical execution plans in action   tech republic
See sql server graphical execution plans in action tech republicKaing Menglieng
 
Application sql issues_and_tuning
Application sql issues_and_tuningApplication sql issues_and_tuning
Application sql issues_and_tuningAnil Pandey
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisRed Gate Software
 
Streaming SQL (at FlinkForward, Berlin, 2016/09/12)
Streaming SQL (at FlinkForward, Berlin, 2016/09/12)Streaming SQL (at FlinkForward, Berlin, 2016/09/12)
Streaming SQL (at FlinkForward, Berlin, 2016/09/12)Julian Hyde
 
Splunk Ninjas: New features, pivot, and search dojo
Splunk Ninjas: New features, pivot, and search dojoSplunk Ninjas: New features, pivot, and search dojo
Splunk Ninjas: New features, pivot, and search dojoSplunk
 
TensorFlow Extension (TFX) and Apache Beam
TensorFlow Extension (TFX) and Apache BeamTensorFlow Extension (TFX) and Apache Beam
TensorFlow Extension (TFX) and Apache Beammarkgrover
 

Was ist angesagt? (20)

Sql performance tuning
Sql performance tuningSql performance tuning
Sql performance tuning
 
Data all over the place! How SQL and Apache Calcite bring sanity to streaming...
Data all over the place! How SQL and Apache Calcite bring sanity to streaming...Data all over the place! How SQL and Apache Calcite bring sanity to streaming...
Data all over the place! How SQL and Apache Calcite bring sanity to streaming...
 
Introduction to Databases - query optimizations for MySQL
Introduction to Databases - query optimizations for MySQLIntroduction to Databases - query optimizations for MySQL
Introduction to Databases - query optimizations for MySQL
 
How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...
 
Cost-based Query Optimization in Apache Phoenix using Apache Calcite
Cost-based Query Optimization in Apache Phoenix using Apache CalciteCost-based Query Optimization in Apache Phoenix using Apache Calcite
Cost-based Query Optimization in Apache Phoenix using Apache Calcite
 
Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
Optimization in essbase
Optimization in essbaseOptimization in essbase
Optimization in essbase
 
R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...
R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...
R Tutorial For Beginners | R Programming Tutorial l R Language For Beginners ...
 
Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning Tips
 
U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)
 
Hyperion essbase basics
Hyperion essbase basicsHyperion essbase basics
Hyperion essbase basics
 
Power of SPL Breakout Session
Power of SPL Breakout SessionPower of SPL Breakout Session
Power of SPL Breakout Session
 
U-SQL Partitioned Data and Tables (SQLBits 2016)
U-SQL Partitioned Data and Tables (SQLBits 2016)U-SQL Partitioned Data and Tables (SQLBits 2016)
U-SQL Partitioned Data and Tables (SQLBits 2016)
 
See sql server graphical execution plans in action tech republic
See sql server graphical execution plans in action   tech republicSee sql server graphical execution plans in action   tech republic
See sql server graphical execution plans in action tech republic
 
Application sql issues_and_tuning
Application sql issues_and_tuningApplication sql issues_and_tuning
Application sql issues_and_tuning
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony Davis
 
Streaming SQL (at FlinkForward, Berlin, 2016/09/12)
Streaming SQL (at FlinkForward, Berlin, 2016/09/12)Streaming SQL (at FlinkForward, Berlin, 2016/09/12)
Streaming SQL (at FlinkForward, Berlin, 2016/09/12)
 
Splunk Ninjas: New features, pivot, and search dojo
Splunk Ninjas: New features, pivot, and search dojoSplunk Ninjas: New features, pivot, and search dojo
Splunk Ninjas: New features, pivot, and search dojo
 
TensorFlow Extension (TFX) and Apache Beam
TensorFlow Extension (TFX) and Apache BeamTensorFlow Extension (TFX) and Apache Beam
TensorFlow Extension (TFX) and Apache Beam
 

Ähnlich wie Brad McGehee Intepreting Execution Plans Mar09

Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008paulguerin
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluationavniS
 
How to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon RedshiftHow to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon RedshiftAWS Germany
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning Arno Huetter
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsDave Stokes
 
dotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesdotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesJavier García Magna
 
A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...Editor IJCATR
 
A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...Editor IJCATR
 
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...Dave Stokes
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql TuningChris Adkin
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL ServerRajesh Gunasundaram
 
Db performance optimization with indexing
Db performance optimization with indexingDb performance optimization with indexing
Db performance optimization with indexingRajeev Kumar
 
PostgreSQL Table Partitioning / Sharding
PostgreSQL Table Partitioning / ShardingPostgreSQL Table Partitioning / Sharding
PostgreSQL Table Partitioning / ShardingAmir Reza Hashemi
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetLucian Oprea
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 

Ähnlich wie Brad McGehee Intepreting Execution Plans Mar09 (20)

Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluation
 
How to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon RedshiftHow to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon Redshift
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
dotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesdotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelines
 
A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...
 
A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...A Review of Data Access Optimization Techniques in a Distributed Database Man...
A Review of Data Access Optimization Techniques in a Distributed Database Man...
 
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Teradata sql-tuning-top-10
Teradata sql-tuning-top-10Teradata sql-tuning-top-10
Teradata sql-tuning-top-10
 
Db performance optimization with indexing
Db performance optimization with indexingDb performance optimization with indexing
Db performance optimization with indexing
 
San diegophp
San diegophpSan diegophp
San diegophp
 
PostgreSQL Table Partitioning / Sharding
PostgreSQL Table Partitioning / ShardingPostgreSQL Table Partitioning / Sharding
PostgreSQL Table Partitioning / Sharding
 
Cassandra data modelling best practices
Cassandra data modelling best practicesCassandra data modelling best practices
Cassandra data modelling best practices
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_Cheatsheet
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 

Mehr von Mark Ginnebaugh

Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015Mark Ginnebaugh
 
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction Mark Ginnebaugh
 
Platfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big DataPlatfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big DataMark Ginnebaugh
 
Microsoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary KeysMicrosoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary KeysMark Ginnebaugh
 
DesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL ServerDesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL ServerMark Ginnebaugh
 
San Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetingsSan Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetingsMark Ginnebaugh
 
Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013Mark Ginnebaugh
 
Microsoft SQL Server Continuous Integration
Microsoft SQL Server Continuous IntegrationMicrosoft SQL Server Continuous Integration
Microsoft SQL Server Continuous IntegrationMark Ginnebaugh
 
Hortonworks Big Data & Hadoop
Hortonworks Big Data & HadoopHortonworks Big Data & Hadoop
Hortonworks Big Data & HadoopMark Ginnebaugh
 
Microsoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join OperatorsMicrosoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join OperatorsMark Ginnebaugh
 
Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013Mark Ginnebaugh
 
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball ApproachMicrosoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball ApproachMark Ginnebaugh
 
Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012Mark Ginnebaugh
 
Microsoft Data Mining 2012
Microsoft Data Mining 2012Microsoft Data Mining 2012
Microsoft Data Mining 2012Mark Ginnebaugh
 
Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012Mark Ginnebaugh
 
Business Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best PracticesBusiness Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best PracticesMark Ginnebaugh
 
Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence Mark Ginnebaugh
 
Microsoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud ReadyMicrosoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud ReadyMark Ginnebaugh
 
Microsoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data ServicesMicrosoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data ServicesMark Ginnebaugh
 
Microsoft SQL Server PowerPivot
Microsoft SQL Server PowerPivotMicrosoft SQL Server PowerPivot
Microsoft SQL Server PowerPivotMark Ginnebaugh
 

Mehr von Mark Ginnebaugh (20)

Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015
 
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
 
Platfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big DataPlatfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big Data
 
Microsoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary KeysMicrosoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary Keys
 
DesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL ServerDesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL Server
 
San Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetingsSan Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetings
 
Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013
 
Microsoft SQL Server Continuous Integration
Microsoft SQL Server Continuous IntegrationMicrosoft SQL Server Continuous Integration
Microsoft SQL Server Continuous Integration
 
Hortonworks Big Data & Hadoop
Hortonworks Big Data & HadoopHortonworks Big Data & Hadoop
Hortonworks Big Data & Hadoop
 
Microsoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join OperatorsMicrosoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join Operators
 
Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013
 
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball ApproachMicrosoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
 
Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012
 
Microsoft Data Mining 2012
Microsoft Data Mining 2012Microsoft Data Mining 2012
Microsoft Data Mining 2012
 
Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012
 
Business Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best PracticesBusiness Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best Practices
 
Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence
 
Microsoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud ReadyMicrosoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud Ready
 
Microsoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data ServicesMicrosoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data Services
 
Microsoft SQL Server PowerPivot
Microsoft SQL Server PowerPivotMicrosoft SQL Server PowerPivot
Microsoft SQL Server PowerPivot
 

Kürzlich hochgeladen

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Kürzlich hochgeladen (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Brad McGehee Intepreting Execution Plans Mar09

  • 1. Presented to the San Francisco SQL Server User Group www.bayareasql.org March 11, 2009 Brad M McGehee Microsoft SQL Server MVP Director of DBA Education Red Gate Software bradmcgehee@hotmail.com
  • 2. You are a SQL Server DBA or developer with novice to intermediate knowledge of SQL Server. You have a basic understanding of indexing and Transact-SQL. You want to learn the basics of how to read and interpret Execution Plans so that you can better understand how your queries are executing, and so that you can better figure out ways to optimize them. The difference between a run-of-the-mill DBA/Developer from an exceptional DBA/Developer is that the exceptional DBA/Developer thoroughly understands how to use their available tools to their full potential.
  • 3. A execution plan, simply put, describes the data retrieval/storage methods chosen by the Query Optimizer to execute a specific query. So why is this important to know? If you understand how a query was executed by SQL Server, you have the information you need to help you to figure out ways to potentially optimize it.
  • 4. T-SQL is sent to the relational engine. T-SQL is parsed to check to see if it is written correctly. T-SQL is next run through the algebrizer, which resolves all the names of the various objects, tables and columns. Algebrizer output is sent to Query Optimizer. Then: Trivial plan may be generated. Otherwise, cost-based calculations are performed to identify the best way to execute the query. In other words, an execution plan is created. Index and column statistics are used during above cost-based calculations to help the query optimizer determine the best execution plan. The better the statistics, the better the execution plan. Note: DDL T-SQL is not optimized, only DML T-SQL
  • 5. The creation of an execution plan takes time. Not every execution option is always explored, a “good enough” execution plan is often generated, then sent to the database engine for execution. The execution plan is estimated, and may change when the T-SQL is actually executed by the database engine. Execution plans are usually cached (in the plan cache) for later use so that it can be reused if an identical (or paramerized) query is submitted for execution again. Reusing a cached execution plan can save time because a new execution plan does not have to be recreated each time the same query is re-executed.
  • 6. Text (Deprecated) Harder for many people to read XML (Storage Format) XML code is not really designed to be read directly by DBAs Can be saved and shared with others (portable) Can be displayed in graphical format (main use) Graphical (Display Format) Generally easier to read and understand by beginners Is produced from XML execution plan Our focus today Demo
  • 7.
  • 8. Estimated Produced without running the query. Displays estimated data only. Can save time and resources. Can’t be used if the query creates object it needs to use: i.e. temp table. Not aways accurate, can be misleading, especially if data is skewed, or the statistics are outdated, or if parallelism is involved. Actual Produced after a query actually runs, may or may not be same as estimated execution plan. Displays estimated and actual results. Demo
  • 9. SSMS (our choice for today) SET commands (some shown in previous demo) Profiler (Showplan XML Event, shows estimated plan) SQL Server 2005 Performance Dashboard SQL Server 2008 Data Collector
  • 10. Demo Overview of Graphical Execution Plan Screen Using the Zoom Button (Around, In, Out, Fit) Learning to Read from Right to Left and Top to Bottom Learning about Icons (operators) Learning about costs (per operator) Learning about Tool Tips (and Properties) Learning about Arrows Executing Multiple Queries
  • 11. Each operator implements a single basic operation, such as: Scanning data from a table Seeking data in a table Aggregating data Sorting Joining two data sets Etc. In total, there are 79 different operator that can be included in an execution plan.
  • 12. Logical and physical operators
  • 13. Logical and physical operators
  • 14. There are 79 Graphical Execution Plan icons.
  • 15. SELECT Table Scan Clustered Index Scan Clustered Index Seek Non-Clustered Scan Non-Clustered Index Seek RID Lookup Key Lookup Sort Joins (loop, merge, hash) Parallelism (special case)
  • 16. Represents the end results of a SELECT query. Good place to start when evaluating any execution plan. To optimize performance, the number of rows that are returned should be the minimum number of rows necessary to meet the needs of the query. Similar icons are available for INSERT, UPDATE, and DELETE.
  • 17. Seeing a table scan often indicates a problem that needs to be addressed. A table scan indicates that every row in the table had to be examined to see if it met the query criteria, which can mean slow performance if there are a large numbers of rows. A table scan indicates there is no clustered index on the table, and the table is a heap. In most cases, you will want to add a clustered index to every table, as it has the potential of boosting the performance of the query, even if a clustered index scan is conducted. This is because leaf nodes of the clustered index are stored together (logically, and hopefully physically). In a heap, they are not, which can hurt performance.
  • 18. A clustered index scan is a scan of all the rows of a table that has a clustered index. Like a table scan, clustered index scans can be slow and use up lots of server resources. Generally, clustered index scans should generally be avoided (but better than table scans). On the other hand, when tables are small or many rows are returned, then a clustered index scan might be the fastest way to return data.
  • 19. If there is an available and useful index, and there is a sargeable WHERE clause, the query optimizer can usually, very quickly, identify the rows to be returned and return them without having to scan each row of the table. Ideally, for best query performance, clustered index seeks should be as used often as feasible. Consider them the “golden standard” for returning data. Of course, there are exceptions, as we will see in the demo.
  • 20. All records in the table are scanned, and all rows that match the WHERE clause are returned. As with all scans, it can be slow and require extra I/O resources. Generally, non-clustered index scans should be avoided.
  • 21. A non-clustered index is used to identify the row(s) to be returned, so every row does not need to be scanned (assumes sargeable WHERE clause). This is generally much faster than a non-clustered index scan. Like clustered index seeks, non-clustered index seeks are generally a good thing. One exception is if bookmark (RID or Key) lookups occur as part of the non-clustered index seek, then performance may lag if many rows are returned.
  • 22. A RID Lookup is generally an indicator of a performance issue. A RID Lookup is a form of a bookmark index lookup on a table without a clustered index (a heap). While RID Lookups are often faster than most “scans,” this is often not the case if many rows have to be returned. Generally, RID Lookups should be eliminated with the addition of an appropriate clustered index, and if necessary, a covering or included index.
  • 23. A key lookup is often an indicator of potentially less than optimal performance. A key lookup is a bookmark lookup on a table with a clustered index. A key lookup is generally faster than a RID lookup. While key lookups are often faster than most “scans,” this is not always the case, especially if a lot of data needs to be returned. Often, key lookups should be eliminated with the addition of a covering or included index.
  • 24. Sorts occur when you specify that returned data be ordered. Sorts may also occur even if you don’t use the ORDER clause. Sorts are normal and aren’t generally a problem. But if you return too much data, then sorts may take a lot of resources (including tempdb), and you should identify ways of reducing the number of rows returned.
  • 25. Loop: For each row in the top (outer) input, scan the bottom (inner) input, and output matching rows. Merge: Match rows from two suitably sorted input tables exploiting their sort order. Hash: Use each row from the top input (table) to build a hash table, and each row from the bottom input (table) to probe into the hash table, outputting all matching rows. More on next page
  • 26. There is no “ideal join,” it all depends on the data being joined. A join can occur in an execution plan even if there is no JOIN statement in a query. From a resource perspective, a nested loop join uses fewer resources, and seeing one generally is a good indicator of good overall performance. Often best for smaller joins. Merge and hash joints use more resources and may be an indicator that too much data is being returned. Demo
  • 27. Parallelism is used to take a query, break it into two or more parts, execute it in parallel, then recombine the parts. Distribute Stream: Takes a single input stream and produces multiple output streams. Gather Stream: Consumes multiple input streams and produces a single output stream by combining the input streams. Repartition Stream: Consumes multiple streams and produces multiple streams of records. Bitmap Create: Bitmap filtering speeds up query execution by eliminating rows with key values that cannot produce any join records before passing rows through another operator. Parallelism may or may not boost query performance. Note: The two arrows in a regular icon indicate parallelism was used for that operator
  • 28. This is just a small sample of the things you can do with Graphical Execution Plans. The learning curve for learning about Graphical Execution Plans is high, but worth the effort. Graphical Execution Plans are a powerful tool to help DBAs understand how a query executes. Based on the information provided by an execution plan, and the DBA’s knowledge of SQL Server, many queries (and indexes) can often be optimized.
  • 29. Please ask questions loud enough for everyone to hear.
  • 30. Free E-Books: www.sqlservercentral.com/Books Check these out: SQL Server 2005/2008 Books Online (of course) www.SQLServerCentral.com www.Simple-Talk.com www.SQL-Server-Performance.Com Contact me at: bradmcgehee@hotmail.com Blogs: www.simple-talk.com/community/blogs/brad_mcgehee/default.aspx http://www.sqlservercentral.com/blogs/aloha_dba/default.aspx http://twitter.com/bradmcgehee