Mastering the Basics of SQL Server Query Optimization

Learn to Create Optimal Execution Plans for Your Queries
4.3 (30 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
305 students enrolled
Instructed by Mike West IT & Software / Other
$19
$20
5% off
Take This Course
  • Lectures 44
  • Length 1.5 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 2/2016 English

Course Description

Student Warning: Even though this is a beginners class it's fast paced and will require some outside study on your part.

I've included 4 different preview lessons so you could better gauge the speed of the course. Please take a moment to preview all of them. If those lessons are too fast then please take this course after you've taken my entry level courses. Thanks.... Mike

Recent Unsolicited Testimonials

“Learned lots from this well constructed and easy to follow course - thanks Mike!” – Caroline

“Feel much more confident in MSSQL now. Thanks!” Jef Yo

“This short course is excellent and will give you a good understanding of the basics in SQL server administration.” Luke Dunn

In this course we are going to delve into the Query Optimizer, easily one of the most complicated pieces of software ever written.

The Query Optimizer is the SQL Server component that tries to give you an optimal execution plan for your queries. The Query Optimizer tries to find that execution plan as quickly as possible. Not the perfect plan but a good one.

The SQL Server Query Optimizer is a cost-based optimizer. It analyzes a number of execution plans for a given query, estimates the cost of each of these plans, and chooses the plan with the lowest cost.

The optimizer seeks to find balance between the optimization time and the quality of the selected plan.

The course will be a balance of hands on query performance tuning and understanding the basics of the optimizer’s architecture.

We are going to learn about the execution engine, statistics and cost estimation, index selection and the optimization process.

At the core of the SQL Server Database Engine are two major components: the storage engine and the query processor also called the relational engine.

In this course our sole focus will be on the query processor. This part of the engine accepts all queries submitted to SQL Server and creates a plan for optimal execution.

See you in the course!!!

What are the requirements?

  • This course was designed for anyone with a working knowledge of relational databases, specifically SQL Server.
  • It can be anything other than Express also
  • Other than SQL Server nothing else is needed to take the course.
  • I've included code samples for the course in the Course Download lecture.
  • You will need to download and install SQL Server 2012, 2014 or 2016 Express Edition
  • You'll also need to download a copy of the Adventureworks database.

What am I going to get from this course?

  • At the conclusion of this course you'll understand how the optimizer works at a very high level.
  • You will be able to read showplans. These are created when a query is executed.
  • You'll understand the caching mechanisms behind SQL Server optimizer.

What is the target audience?

  • This is a mid level course aimed at those who have a working foundation of SQL Server.
  • This is not an entry level course.
  • Everything you need to take the course will be included. There are no items you'll have to purchase.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Introduction - How the Query Optimizer Works
01:26

What are we going to cover in this course.

Please take a quick perusal of this and other lectures to get a clearer idea on what's we will be covering in the course.

00:59

In this lecture I want to make sure you are in the right place.

This course is about the Query Optimizer and about the basics of reading execution plans.

Course Downloads
Article
01:16

The SQL Server Engine has two major componets.

In this lecture let's find out what they are.

01:30

When any query is issued in SQL Server a plan is created.

This plan is created via a variety of steps.

Let's talk about them in this lecture.

01:44

In this lecture we will define what a Search Space is.

01:32

How much does it cost to do all this?


Let's find out.

01:20

As a general rule we want plan cache reuse.

It's a good thing.

Let's talk about it in this lecture.

00:51

Some times new plans will have to be created.

What are a few of the major causes of recompiles?

04:02

Let's cover the new vernacular in video format.

Article

Let's wrap up what we've covered in this section.

Quiz
10 questions
Section 2: Execution Plans
Article

There is a lot new vernacular for the student starting in execution plan analysis.

Don't become frustrated or rush through the course.

This will take time.

02:34

In this lecture let's learn about the basic parts and terminology of an execution plan.

Article

Why are operators called iterators?

Let's find out why in this lecture.

01:37

There are a variety of methods we can use to look at execution plans.

However, the vast majority use the right click approach to view them pictorially.

01:56

The two most fundamental access methods in SQL Server.

Let's define them.

02:09

The word scan in database parlance means bad.

Let's see some scans in action and learn how to spot them in this lecture.

03:06

The "seek" is the most efficient way we can navigate our structures.

Let's take a look at exactly what that is in this lecture.

04:08

One of the most common kinds of problem areas in real world plans.

Let's define them and correct them.

02:02

Aggregations aren't difficult but there are some nuances with the operators.

Let's cover them in this lecture.

03:05

What's a Hast Match operator?

In this lecture we will find out.

01:54

SQL Server uses to implement logical joins: the Nested Loops Join, the Merge Join and the Hash Join.

It is important to understand that no join algorithm is better than the others, and that the Query Optimizer will select the best join algorithm.

01:25

The merge join requires both inputs to be sorted on the merge columns, which are defined by the equality (ON) clauses of the join predicate.

Let's look at an example with a merge join.

01:17

Hash joins are used for many types of set-matching operations: inner join; left, right, and full outer join; left and right semi-join; intersection; union; and difference.

Let's learn about Hash Joins in this lecture.

01:13

Parallelism is a complicated topic.

Let's define it at a very high level in this lecture.

Article

There are lots of new terms in this lecture.

You many want to print them out.

Article

Let's look at the high points of this section.

Quiz
10 questions
Section 3: Cost Estimation
01:35

Statistics refers to the statistical information about the distribution of values in one or more columns of a table or an index.

There are three key sections of the output for learning about statistics.

We will cover them in this lecture.

Article

Let's pause for one second and keep several critical aspects of learning about statistics in mind.

04:24

There are different ways you can view the details of the statistics objects. You can use the DBCC SHOW_STATISTICS command. DBCC SHOW_STATISTICS shows the header, histogram, and density vector based on data stored in the statistics object.

01:17
Substantial data change operations (like insert, update, delete, or merge) change the data distribution in the table or indexed view.
01:16

Let's look at an execution plan and some stale statistics.

Maintaining Statistics
01:25
Setting Up Statistics Maintenance Job
04:35
Terminology
Article
Summary
Article
Quiz
10 questions
Section 4: Real World Examples: Fixing the Most Common Issues
03:23

One of the most common operators you'll come across

You'll see it almost every day.

Let's learn what to look for and how to correct them.

02:46

We use this in conjunction with execution plan analysis.

This gives us a more granular insight into how the pages move between the buffer pool and the disk.

SET STATISTICS PROFILE ON
Article
02:44

You can indeed add non-clustered indexes to heaps and make a dramatic improvement on your queries.

Let's look at how in this lecture.

03:29

There's no such thing as a good sort.

Let's learn how to get rid of them in this lecture.

02:00

Easy to spot, spools are a good place to improve query performance.

Summary
Article
Quiz
10 questions
Section 5: Conclusion
Article

Congratulations!!!!!

You've completed this course on execution plan analysis.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Mike West, SQL Server Evangelist

I've been a production SQL Server DBA most of my career.

I've worked with databases for over two decades. I've worked for or consulted with over 50 different companies as a full time employee or consultant. Fortune 500 as well as several small to mid-size companies. Some include: Georgia Pacific, SunTrust, Reed Construction Data, Building Systems Design, NetCertainty, The Home Shopping Network, SwingVote, Atlanta Gas and Light and Northrup Grumman.

Experience, education and passion

I learn something almost every day. I work with insanely smart people. I'm a voracious learner of all things SQL Server and I'm passionate about sharing what I've learned. My area of concentration is performance tuning. SQL Server is like an exotic sports car, it will run just fine in anyone's hands but put it in the hands of skilled tuner and it will perform like a race car.

Certifications

Certifications are like college degrees, they are a great starting points to begin learning. I'm a Microsoft Certified Database Administrator (MCDBA), Microsoft Certified System Engineer (MCSE) and Microsoft Certified Trainer (MCT).

Personal

Born in Ohio, raised and educated in Pennsylvania, I currently reside in Atlanta with my wife and two children.

Ready to start learning?
Take This Course