Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Key to the Database Engine

Similar presentations


Presentation on theme: "The Key to the Database Engine"— Presentation transcript:

1 The Key to the Database Engine
Execution Plan Essentials The Key to the Database Engine Eugene Meidinger, BI Consultant, All Lines Technology

2 BI Consultant, All Lines Technology
Went from SQL Newbie to SQL Pro in the last 6 years. Experience with T-SQL, SSRS and Power BI Pluralsight Author Author of video training on Pluralsight. Currently focusing on Power BI content Eugene Meidinger BI Consultant, All Lines Technology Pittsburgh PUG co-leader Help lead the Pittsburgh Power BI User Group. /eugenemeidinger @sqlgene

3 Agenda This is an introductory session on execution plans.
What are execution plans? How do you read them? What do the operators mean? What’s new since SQL Server 2012? Demos, Demos, Demos

4 What are Execution Plans?
An execution plan represents the steps the database engine takes. When the Database Engine processes a query, it creates a series of steps You can think of this like a recipe, or driving directions Execution plans give you insight into the choices the engine made Some plans can be wildly inefficient (human error, bad statistics, etc.) Execution plans are cached for future runs

5 Database Engines are like GPS Devices
You use a GPS device to tell you how to get from point A to point B as efficiently as possible A driving plan is a series of steps or operations (turn left, turn right, go straight, etc.) A driving plan has a set of costs (miles, gas, time, tolls, etc.) A GPS device usually provides multiple options, with different costs Part of the Database Engine works to figure out how to get data from disk to the client as efficiently as possible An execution plan is a series of steps or operations (Index scan, filter data, SELECT) An execution plan has a set of costs (IO, CPU, RAM, time) The database engine will produce multiple potential execution plans

6 How Do We View Execution Plans?
We have three different options. Go to Query Click Include Actual Execution Plan Or, press Ctrl + M Or, click the execution plan icon on the toolbar

7 What Does a Plan Look Like?

8 How to Read an Execution Plan
It’s a roadmap for your data. Read from right to left and top to bottom Imagine everyone driving towards the SELECT Icons represent operators Thinks of operators as turns on your road trip Operators have costs below them Arrow represent data flow Think of them as traffic indicators Bigger arrows mean more rows Hover over icons and arrows for more detail

9 Missing Indexes The database engine will suggest missing indexes.

10 Types of Operators There are a few broad categories. Gathering Data
Joining Data Manipulating Data MISC

11 Gathering Data This is the starting point for any execution plan.
Table scan Clustered index scan Clustered index seek Nonclustered index scan Nonclustered index seek RID lookup Key lookup

12 SARGability When can you use your indexes?
SARGability (Search Argument) means your query can use your indexes. Imagine if I asked for all the Smiths from the phonebook. That’s SARGable. Imagine if I asked for all Last names with an R. That’s not SARGable. Manipulating a column in your where clause can break SARGability.

13 Joining Data There are three types of joins Nested Loop Join
Ideal when one dataset is small Merge Join Ideal when both datasets are sorted Hash Join Ideal for large datasets Memory intensive!!!

14 Manipulating Data There are a lot of ways to manipulate data. These are a few. Compute Scalar Filter Sort Top

15 What’s new? A lot has changed since 2008 R2. Compare Showplan
Cardinality Estimator Row Level Security Live Query Statistics Query Store Adaptive Query Plans

16 Execution Plans Demo

17 Learn more from Eugene Meidinger
@sqlgene


Download ppt "The Key to the Database Engine"

Similar presentations


Ads by Google