Introduction to Execution Plans

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

Understanding SQL Server Query Execution Plans
SQL Server performance tuning basics
EXECUTION PLANS By Nimesh Shah, Amit Bhawnani. Outline  What is execution plan  How are execution plans created  How to get an execution plan  Graphical.
Query Execution, Concluded Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems November 18, 2003 Some slide content may.
1 Implementation of Relational Operations Module 5, Lecture 1.
Virtual techdays INDIA │ 9-11 February 2011 SQL 2008 Query Tuning Praveen Srivatsa │ Principal SME – StudyDesk91 │ Director, AsthraSoft Consulting │ Microsoft.
Tempdb Parasites Jason Hall-Dir. of Client SQL Sentry Blog-jasonhall.blogs.sqlsentry.net.
1 Implementation of Relational Operations: Joins.
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
Around the world (of query plan operators) in 50 minutes David Morrison BI Consultant.
Query Execution. Where are we? File organizations: sorted, hashed, heaps. Indexes: hash index, B+-tree Indexes can be clustered or not. Data can be stored.
Sorting and Joining.
Query Execution Query compiler Execution engine Index/record mgr. Buffer manager Storage manager storage User/ Application Query update Query execution.
Alon Levy 1 Relational Operations v We will consider how to implement: – Selection ( ) Selects a subset of rows from relation. – Projection ( ) Deletes.
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
Thinking in Sets and SQL Query Logical Processing.
Eugene Meidinger Execution Plans
Fundamentals of Great SQL Query Performance Matt Wigdahl, ScriptPro LLC.
Dave LinkedIn
How to kill SQL Server Performance Håkan Winther.
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Execution Plans Detail From Zero to Hero İsmail Adar.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
SQL Server Statistics and its relationship with Query Optimizer
Tuning Transact-SQL Queries
Query Tuning without Production Data
Query Tuning without Production Data
Query Tuning without Production Data
Reading execution plans successfully
Reading Execution Plans Successfully
Introduction to Execution Plans
Chapter 15 QUERY EXECUTION.
Examples of Physical Query Plan Alternatives
The Key to the Database Engine
Now where does THAT estimate come from?
Cardinality Estimator 2014/2016
Physical Join Operators
Relational Operations
Query Optimization Techniques
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Execution Plans Demystified
Deep Dive into Adaptive Query Processing
Transactions, Locking and Query Optimisation
SQL Server 2016 Execution Plan Analysis Liviu Ieran
Reading Execution Plans Successfully
Selected Topics: External Sorting, Join Algorithms, …
SQL Server Query Plans Journeyman and Beyond
Introduction to reading execution plans
Lecture 2- Query Processing (continued)
Parameter Sniffing: the Good, the Bad, and the Ugly
Dave Bland LinkedIn SQL Server Execution Plans: How to use them to find performance bottlenecks Dave Bland LinkedIn
Introduction to Execution Plans
Parameter Sniffing: the Good,the Bad, and the Ugly
Implementation of Relational Operations
Parameter Sniffing: the Good, the Bad, and the Ugly
Query Tuning Fundamentals
EXECUTION PLANS Quick Dive.
Execution plans Eugene
Evaluation of Relational Operations: Other Techniques
Diving into Query Execution Plans
From adaptive to intelligent: query processing in SQL Server 2019
Query Optimization Techniques
Reading execution plans successfully
Introduction to Execution Plans
Welcome!.
All about Indexes Gail Shaw.
Presentation transcript:

Introduction to Execution Plans Lance Tidwell

Lance Tidwell DBA, TicketCity @Lance_LT . silentdba@gmail.com

What is an Execution Plan? It is a map of the tables, indexes, and operations that SQL will use to execute the query.

How is the Execution Plan Created? Query Optimizer: Builds the best plan it can based on the stats of the tables being used in the query.

How is the Execution Plan Created? Query Optimizer: Builds the best plan it can based on the stats of the tables being used in the query.

How is the Execution Plan Created? Query Optimizer: Builds the best plan it can based on the stats of the tables being used in the query.

How is the Execution Plan Created? Query Optimizer: Builds the best plan it can based on the stats of the tables being used in the query.

How is the Execution Plan Created? Query Optimizer: Builds the best plan it can based on the stats of the tables being used in the query.

When are Plans Removed from Plan Cache? Changing structure or schema of a table being used in the plan. Updating stats that are used in the plan. Dropping/ changing index being used in plan. Plan is “aged” out of cache.

Common Operators Index Scan : Scans thru all the entire index touching every single page. Index Seek : Only touches the qualifying row and pages that contain those rows Table Scan : Scan entire table. Also means that you don’t have a clustered index on table Key Lookup : Retrieves info from the clustered index that is not in the non-clustered index. Which means you have non-covering index.

Common Operators (Join Types) Nested Loops : Performs a search on the inner table for each row of the outer table (Cursor). Good for small amount of data. Merge Join : Requires both inputs to be sorted on join keys. Usually very fast. Can be a issue if additional sort operators are required. Hash Match : Uses a hash function to make a hash table of top set of data and then go thru bottom set using same hash function to probe hash table. Used for large set of data or when there aren’t good enough indexes in place to do one of the other joins.

Types of Execution Plans Estimated Execution Plan : Is the plan the optimizer generated without any actual execution data just estimations Actual Execution Plan : Is the similar to the estimate plan excepts has some actual execution data to help you see how well the plan is performing for real data Live Query Stats ( SQL Server 2014 and above): Will show you the estimate plan with live stats as it executes. Great for visualizing and seeing the bottlenecks in longer running procs.

DEMO

Parameter Sniffing When a stored procedure is run for the first time the values of the parameters sent in are used to make the best plan for those specific values and that plan is used for subsequent calls to the procedure until that plan is removed from the plan cache. This is a great thing that is helps our your performance (most of the time). http://usergroup.tv/videos/parameter-sniffing-the-good-the-bad-and-the-ugly

Plan Warnings Implicit Conversion : When SQL has to convert your data type because they mismatch. Can cause scans to occur instead of seeks TempDB Spill : When the memory grant for a sort is bigger than expected it has to move the sort to disk in TempDB

DEMO

Cardinality Estimator The Cardinality Estimator is what is used to look at the stats of the table and come up with the estimated number of rows for the execution plans. In SQL 2014 this got it first major upgrade since SQL 7.0. Trace Flag 9481 will disable the new Cardinality Estimator. Trace Flag 2312 will enable the new Cardinality Estimator on SQL 2012 and above. https://thomaslarock.com/2014/07/sql-2014-cardinality-estimator-care-part- 2/ https://www.brentozar.com/archive/2014/04/sql-2014-cardinality-estimator- eats-bad-tsql-breakfast/

DEMO

SQL Server 2017 Adaptive Query Processing Adaptive Joins Automatic Tuning

Thank You!!! silentdba@gmail.com @Lance _LT Parameter Sniffing the Good and the Bad 20 |