SQL Server › Query Optimization & Plans

What is an execution plan in SQL Server, and how does it help you understand query performance?

Beginner

Answer

An execution plan shows exactly how SQL Server intends to carry out a query, including which indexes it plans to use, how it will join tables together, and in what order operations will happen, giving you visibility into the actual strategy behind a query rather than just seeing its final results.
SET SHOWPLAN_XML ON;
GO
SELECT * FROM Orders WHERE CustomerId = 123;
GO
Real-world example A developer views the execution plan for a slow running query and immediately spots a full table scan happening where an index seek should have been used, pointing directly to a missing index as the root cause.

Common follow-ups: What is the difference between an estimated and an actual execution plan?;How do you read an execution plan visually in SQL Server Management Studio?