Execution Plans — Complete Guide
Execution Plans — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of SQL Server Tutorial on Toolliyo Academy.
On this page
SQL Server Tutorial · Lesson 63 of 100
Execution Plans
SQL basics ✓ → Queries ✓ → Advanced
Advanced · 3 — Procedures · ~10 min · SQL — Advanced SQL Server
What is this?
An execution plan shows how SQL Server runs a query: seeks, scans, joins, sorts, estimates vs actuals. Actual plans include runtime numbers.
Why should you care?
Plans turn “it’s slow” into “clustered index scan of 2M rows” — actionable.
See it live — copy this example
Run in SQL Server Management Studio (SSMS) or Azure Data Studio.
USE DataVerse;
SET STATISTICS XML ON; -- or click Include Actual Execution Plan in SSMS
SELECT o.OrderId, c.FullName
FROM dbo.Orders o
JOIN dbo.Customers c ON c.CustomerId = o.CustomerId
WHERE o.City = N'Mumbai';
SET STATISTICS XML OFF;
What happened?
- STATISTICS XML returns the plan as XML (SSMS renders it graphically).
- Look for thick arrows, scans, and big differences between estimated and actual rows.
Practice next
- Enable Include Actual Execution Plan.
- Run the join query.
- Hover operators and read row counts.
- Compare INNER HASH JOIN hint vs default (lab curiosity).
- Look for Implicit Conversion warnings.
Remember
Plans reveal operators and costs. Prefer actual plans for tuning. Fix the expensive operator first.
Slow join found in plan
DataVerse support query scanned Orders.
Outcome: Index on City + CustomerId fixed the seek.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!