Skip to content

Commit 39ce74b

Browse files
author
pmasl
committed
Revamped performance related documentation,: updated pictures, organized TOC, and added new features
1 parent 428e080 commit 39ce74b

60 files changed

Lines changed: 816 additions & 195 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/relational-databases/automatic-tuning/automatic-tuning.md

Lines changed: 39 additions & 34 deletions
Large diffs are not rendered by default.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: "Analyze an Actual Execution Plan | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "08/21/2017"
5+
ms.prod: sql
6+
ms.prod_service: "database-engine, sql-database"
7+
ms.reviewer: ""
8+
ms.technology: performance
9+
ms.topic: conceptual
10+
helpviewer_keywords:
11+
- "analyzing execution plans"
12+
- "analyzing actual execution plans"
13+
- "execution plans [SQL Server], analyzing"
14+
ms.assetid: 9e583a18-5f4a-4054-bfe1-4b2a76630db6
15+
author: pmasl
16+
ms.author: pelopes
17+
manager: amitban
18+
---
19+
# Analyze an Actual Execution Plan
20+
[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)]
21+
This topic describes analyze actual graphical execution plans by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] Plan Analysis feature.
22+
23+
> [!NOTE]
24+
> Actual execution plans are generated after the [!INCLUDE[tsql](../../includes/tsql-md.md)] queries or batches execute. Because of this, an actual execution plan contains runtime information, such as actual resource usage metrics and runtime warnings (if any). For more information, see [Display an Actual Execution Plan](../../relational-databases/performance/display-an-actual-execution-plan.md).
25+
26+
Query performance troubleshooting requires significant expertise in understanding query processing and execution plans, in order to be able to actually find and fix root causes.
27+
28+
[!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] includes functionality that implements some degree of automation in the task of actual execution plan analysis, especially for large and complex plans. The goal is to make it easier to find scenarios of inaccurate [Cardinality Estimation](../../relational-databases/performance/cardinality-estimation-sql-server.md) and get recommendations on which possible mitigations may be available.
29+
30+
> [!IMPORTANT]
31+
> Ensure proper testing of proposed mitigations before applying them on production environments.
32+
33+
## To analyze an execution plan for a query
34+
35+
1. Open a previously saved query execution plan file (.sqlplan) using the **File** menu and clicking on **Open File**, or drag a plan file to [!INCLUDE[ssManStudio](../../includes/ssManStudio-md.md)] window. Alternatively, if you just executed a query and chose to display its execution plan, move to the **Execution Plan** tab in the results pane.
36+
37+
2. Right-click in a blank area of the execution plan and click **Analyze Actual Execution Plan**.
38+
39+
![Right-click Analyze Actual Execution Plan](../../relational-databases/performance/media/plananalysismenuoption.png "Right-click Analyze Actual Execution Plan")
40+
41+
3. The **Showplan Analysis** window opens on the bottom. The **Multi Statement** tab is useful when analyzing plans with multiple statements, by allowing the right statement to be analyzed.
42+
43+
4. Select the Scenarios tab to see details on the issues found for the actual execution plan. For each listed operator on the left pane, the right pane shows details about the scenario in the *Click here for more information about this scenario* link, and possible reasons to explain that scenario are listed.
44+
45+
![Execution Plan Analysis results](../../relational-databases/performance/media/plananalysis-scenarios.png "Execution Plan Analysis results")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "Compare and Analyze Execution Plans | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/21/2018"
5+
ms.prod: sql
6+
ms.prod_service: "database-engine, sql-database"
7+
ms.reviewer: ""
8+
ms.technology: performance
9+
ms.topic: conceptual
10+
helpviewer_keywords:
11+
- "Showplan results"
12+
- "execution plans [SQL Server]"
13+
- "queries [SQL Server], tuning"
14+
- "execution plans [SQL Server], how-to topics"
15+
- "SQL Server Management Studio [SQL Server], execution plans"
16+
- "tuning queries [SQL Server]"
17+
ms.assetid: bcd6f094-c613-4835-ae19-4caaadb4bb17
18+
author: pmasl
19+
ms.author: pelopes
20+
manager: amitban
21+
---
22+
# Compare and Analyze Execution Plans
23+
[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)]
24+
This section explains how to compare and analyze execution plans by using Microsoft [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)].
25+
26+
Execution plans graphically display the data retrieval methods chosen by the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Query Optimizer. Execution plans represent the execution cost of specific statements and queries in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] using icons rather than the tabular representation produced by the [SET SHOWPLAN_ALL](../../t-sql/statements/set-showplan-all-transact-sql.md) or [SET SHOWPLAN_TEXT](../../t-sql/statements/set-showplan-text-transact-sql.md) statements. This graphical approach is very useful for understanding the performance characteristics of a query.
27+
28+
[!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] includes functionality that allows users compare two execution plans, for example between perceived good and bad plans for the same query, and perform root cause analysis. Also included is the functionality to perform single query plan analysis, allowing insights into scenarios that may be affecting the performance of a query through analysis of its execution plan.
29+
30+
For more information on query execution plans, see [estimated execution plan](../../relational-databases/performance/display-the-estimated-execution-plan.md), [actual execution plan](../../relational-databases/performance/display-an-actual-execution-plan.md), and the [Query Processing Architecture Guide](../../relational-databases/query-processing-architecture-guide.md).
31+
32+
## In This Section
33+
34+
- [Compare Execution Plans](../../relational-databases/performance/display-the-estimated-execution-plan.md)
35+
36+
- [Analyze an Actual Execution Plan](../../relational-databases/performance/display-an-actual-execution-plan.md)
37+
38+
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: "Compare Execution Plans | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/21/2018"
5+
ms.prod: sql
6+
ms.prod_service: "database-engine, sql-database"
7+
ms.reviewer: ""
8+
ms.technology: performance
9+
ms.topic: conceptual
10+
helpviewer_keywords:
11+
- "comparing execution plans"
12+
- "compare execution plans"
13+
- "plan comparison"
14+
- "execution plans [SQL Server], comparing"
15+
- "Query Store, comparing plans"
16+
ms.assetid: 9e583a18-5f4a-4054-bfe1-4b2a76630db6
17+
author: pmasl
18+
ms.author: pelopes
19+
manager: amitban
20+
---
21+
# Compare execution plans
22+
[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)]
23+
This topic describes how to compare similarities and differences between actual graphical execution plans by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] Plan Comparison feature.
24+
25+
> [!NOTE]
26+
> Actual execution plans are generated after the [!INCLUDE[tsql](../../includes/tsql-md.md)] queries or batches execute. Because of this, an actual execution plan contains runtime information, such as actual resource usage metrics and runtime warnings (if any). For more information, see [Display an Actual Execution Plan](../../relational-databases/performance/display-an-actual-execution-plan.md).
27+
28+
The ability to compare plans is something that database professionals may have to do for troubleshooting reasons:
29+
- Find why a query or batch suddenly slowed down.
30+
- Understand the impact of a query rewrite.
31+
- Observe how a specific performance-enhancing change introduced to the schema design (like a new index) has effectively changed the execution plan.
32+
33+
The **Plan Comparison** menu option allows side-by-side comparison of two different execution plans, for easier identification of similarities and changes that explain the different behaviors for all the reasons stated above. This option can compare between:
34+
- Two previously saved execution plan files (*.sqlplan* extension).
35+
- One active execution plan and one previously saved query execution plan.
36+
- Two selected query plans in [Query Store](../../relational-databases/performance/monitoring-performance-by-using-the-query-store.md).
37+
38+
> [!TIP]
39+
> Plan Comparison works with any *.sqlplan* files, even from older versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. Also, this option enables an offline compare, so there's no need to be connected to a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance.
40+
41+
When two execution plans are compared, regions of the plan that **do essentially the same** are highlighted in the same color and pattern. Clicking on a colored region in one plan will center the other plan on the matching node in that plan. You can still compare unmatched operators and nodes of the execution plans, but in that case you must manually select the operators to compare.
42+
43+
> [!IMPORTANT]
44+
> Only nodes considered to change the shape of the plan are used to check for similarities. Therefore, there may be a node which is not colored in the middle of two nodes that are in the same subsection of the plan. The lack of color in this case implies that the nodes were not considered when checking if the sections are equal.
45+
46+
## To compare execution plans
47+
48+
1. Open a previously saved query execution plan file (.sqlplan) using the **File** menu and clicking on **Open File**, or drag a plan file to [!INCLUDE[ssManStudio](../../includes/ssManStudio-md.md)] window. Alternatively, if you just executed a query and chose to display its execution plan, move to the **Execution Plan** tab in the results pane.
49+
50+
2. Right-click in a blank area of the execution plan and click **Compare Showplan**.
51+
52+
![Right-click Compare Showplan](../../relational-databases/performance/media/plancomparisonmenuoption.png "Right-click Compare Showplan")
53+
54+
3. Choose the second query plan file that you would like to compare with. The second file will open so that you can compare the plans.
55+
56+
4. The compared plans will open a new window, by default with one on top and one on the bottom. The default selection will be the first occurrence of an operator or node that is common in the compared plans, but showing differences between plans. All highlighted operators and nodes exist in both compared plans. Selecting an highlighted operator in the top or left plans automatically selects the corresponding operator in the bottom or right plans. Selecting the root node operator in any of the compared plans (the SELECT node in the picture below) also selects the respective root node operator in the other compared plan.
57+
58+
![Plan comparison of two saved plan files](../../relational-databases/performance/media/plancomparison-plans.png "Plan comparison of two saved plan files")
59+
60+
> [!TIP]
61+
> You can toggle the display of the execution plan comparison to side-by-side, by right-clicking a blank area of the execution plan and selecting **Toggle Splitter Orientation**.
62+
63+
> [!TIP]
64+
> All zooming and navigation options available for execution plans work in plan comparison mode. For more details, see [Display an Actual Execution Plan](../../relational-databases/performance/display-an-actual-execution-plan.md).
65+
66+
5. A dual properties window also opens on the right side, in the scope of the default selection. Properties that exist in both compared operators but have differences will be preceeded by the *not equal* sign (≠) for easier identification.
67+
68+
![Dual properties window](../../relational-databases/performance/media/plancomparison-properties.png "Dual properties window")
69+
70+
6. The **Showplan Analysis** comparison navigation window also opens on the bottom. Three tabs are available:
71+
72+
1. In the **Statement Options** tab, the default selection is *Highlight similar operations* and the same highlighted operator or node in compared plans share the same color and line pattern. Navigate between similar areas in compared plans by clicking on a lime pattern. You can also choose to highlight differences in plans rather similarities, by selecting *Highlight operations not matching similar segments*.
73+
74+
> [!NOTE]
75+
> By default, database names are ignored when comparing plans to allow comparison of plans captured for databases that have differenty names, but share the same schema. For example when comparing plans from databases *ProdDB* and *TestDB*. This behavior can be changed with the *Ignore database name when comparing operators* option.
76+
77+
![Showplan Analysis window](../../relational-databases/performance/media/plancomparison-analysis.png "Showplan Analysis window")
78+
79+
2. The **Multi Statement** tab is useful when comparing plans with multiple statements, by allowing the right statement pair to be compared.
80+
81+
![Multiple statements in compared plan](../../relational-databases/performance/media/plancomparison-multiple.png "Multiple statements in compared plan")
82+
83+
3. In the **Scenarios** tab you can find an automated analysis of some of the most relevant aspects to look at in what relates to [Cardinality Estimation](../../relational-databases/performance/cardinality-estimation-sql-server.md) differences in compared plans. For each listed operator on the left pane, the right pane shows details about the scenario in the *Click here for more information about this scenario* link, and possible reasons to explain that scenario are listed.
84+
85+
![Different estimated rows](../../relational-databases/performance/media/plancomparison-scenarios.png "Different estimated rows")
86+
87+
If this window is closed, right-click on a blank area of a compared plan, and select **Showplan Compare Options** to re-open.
88+
89+
![Plan compare options](../../relational-databases/performance/media/plancomparison-options.png "Plan compare options")
90+
91+
## To compare execution plans in Query Store
92+
93+
1. In Query Store, identify a query that has more than one execution plan. For more information on Query Store scenarios, see [Query Store Usage Scenarios](../../relational-databases/performance/query-store-usage-scenarios.md#identify-and-tune-top-resource-consuming-queries).
94+
95+
2. Use a combination of the SHIFT key and your mouse to select two plans for the same query.
96+
97+
![Select two plans in Query Store](../../relational-databases/performance/media/plancomparison-querystore.png "Select two plans in Query Store")
98+
99+
3. Use the button **Compare the plans for the select query in a seperate window** to start plan comparison. Then steps 4 through 6 of *To compare execution plans* are applicable.
100+
101+
![Compare Showplan in Query Store](../../relational-databases/performance/media/plancomparison-querystoreoption.png "Compare Showplan in Query Store")

docs/relational-databases/performance/database-engine-tuning-advisor.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ manager: craigg
2626
- Manage storage space
2727

2828
## Database Engine Tuning Advisor Benefits
29-
Optimizing query performance can be difficult without a full understanding the database structure and the queries that are run against the database. The Database Engine Tuning Advisor can make this task easier by analyzing the current query plan cache or by analyzing a workload of [!INCLUDE[tsql](../../includes/tsql-md.md)] queries that you create and recommending an appropriate physical design. For more advanced database administrators, DTA exposes a powerful mechanism to perform exploratory what-if analysis of different physical design alternatives. The DTA can provide the following information.
29+
Optimizing query performance can be difficult without a full understanding the database structure and the queries that are run against the database. The **Database Engine Tuning Advisor (DTA)** can make this task easier by analyzing the current query plan cache or by analyzing a workload of [!INCLUDE[tsql](../../includes/tsql-md.md)] queries that you create and recommending an appropriate physical design. For more advanced database administrators, DTA exposes a powerful mechanism to perform exploratory what-if analysis of different physical design alternatives. The DTA can provide the following information.
3030

3131
- Recommend the best mix of rowstore and [columnstore](../../relational-databases/performance/columnstore-index-recommendations-in-database-engine-tuning-advisor-dta.md) indexes for databases by using the query optimizer to analyze queries in a workload.
3232

@@ -44,10 +44,10 @@ manager: craigg
4444

4545
- Consider alternatives in which you supply possible design choices in the form of hypothetical configurations for Database Engine Tuning Advisor to evaluate.
4646

47-
- Tune workloads from a variety of sources including SQL Server Query Store, Plan Cache, SQL Server Profiler Trace file or table, or a .SQL file.
47+
- Tune workloads from a variety of sources including SQL Server Query Store, Plan Cache, SQL Server Profiler Trace file or table, or a .SQL file.
4848

4949

50-
The Database Engine Tuning Advisor is designed to handle the following types of query workloads.
50+
The Database Engine Tuning Advisor is designed to handle the following types of query workloads:
5151

5252
- Online transaction processing (OLTP) queries only
5353

@@ -60,22 +60,22 @@ manager: craigg
6060
- Update-heavy workloads (more data modifications than queries)
6161

6262
## DTA Components and Concepts
63-
Database Engine Tuning Advisor Graphical User Interface
63+
**Database Engine Tuning Advisor Graphical User Interface**
6464
An easy-to-use interface in which you can specify the workload and select various tuning options.
6565

6666
**dta** Utility
6767
The command prompt version of Database Engine Tuning Advisor. The **dta** utility is designed to allow you to use Database Engine Tuning Advisor functionality in applications and scripts.
6868

69-
workload
69+
**workload**
7070
A Transact-SQL script file, trace file, or trace table that contains a representative workload for the databases you want to tune. Beginning with [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)], you can specify the plan cache as the workload. Beginning with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)], you can [specify the Query Store as the workload](../../relational-databases/performance/tuning-database-using-workload-from-query-store.md).
7171

72-
XML input file
73-
An XML-formatted file that Database Engine Tuning Advisor can use to tune workloads. The XML input file supports advanced tuning options that are not available in either the GUI or **dta** utility.
72+
**XML input file**
73+
A XML-formatted file that Database Engine Tuning Advisor can use to tune workloads. The XML input file supports advanced tuning options that are not available in either the GUI or **dta** utility.
7474

7575
## Limitations and Restrictions
7676
The Database Engine Tuning Advisor has the following limitations and restrictions.
7777

78-
- It cannot add or drop unique indexes or indexes that enforce PRIMARY KEY or UNIQUE constraints.
78+
- It cannot add or drop unique indexes or indexes that enforce `PRIMARY KEY` or `UNIQUE` constraints.
7979

8080
- It cannot analyze a database that is set to single-user mode.
8181

0 commit comments

Comments
 (0)