You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/features/automatic-tuning/force-last-good-plan/README.md
+13-11Lines changed: 13 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Forcing last good plan
2
-
This code sample demonstrates how [Automatic tuning in SQL Server 2017 CTP2.0+](https://docs.microsoft.com/sql/relational-databases/automatic-tuning/automatic-tuning) can identify and automatically fix performance problems in your workload.
2
+
This code sample demonstrates how [Automatic tuning in SQL Server 2017 CTP2.0+](https://docs.microsoft.com/sql/relational-databases/automatic-tuning/automatic-tuning) can identify and automatically fix performance problems in your workload.
3
3
4
4
### Contents
5
5
@@ -22,7 +22,7 @@ This code sample demonstrates how [Automatic tuning in SQL Server 2017 CTP2.0+]
22
22
5.**Author:** Jovan Popovic [jovanpop-msft]
23
23
24
24
There are two ways to demonstrate the feature using this sample:
25
-
- Level 300 demo: T-SQL code that simulates workload using T-SQL commands and shows results using dynamic management views.
25
+
- Level 300 demo: T-SQL code that simulates workload using T-SQL commands and shows results using dynamic management views and Query Store UI in SQL Server Management Studio.
26
26
- Level 100-200 demo: ASP.NET application that simulates workload using AJAX requests sent to web server and shows results in the web page. Optionally use Query Store UI in SQL Server Management Studio to show performance regressions.
27
27
28
28
<aname=before-you-begin></a>
@@ -41,19 +41,20 @@ To run this sample, you need the following prerequisites.
41
41
## Run this sample
42
42
43
43
### Setup code
44
-
1.Clone this repository using Git for Windows(http://www.git-scm.com/), or download the zip file.
44
+
1.Download [T-SQL script files in sql-scripts](sql-scripts) folder. Optionally you can clone this repository using [Git for Windows](http://www.git-scm.com/), or download the zip file.
45
45
2. Download the [WideWorldImporters](../../../databases/wide-world-importers) database and restore it on your server.
46
46
3. Execute setup.sql script on your [WideWorldImporters](../../../databases/wide-world-importers) database that will add necessary stored procedures and indexes.
47
47
48
48
### Configure ASP.NET sample (Only for ASP.NET Sample)
49
-
1. Open appsettings.json file in the root of the folder and change server, database, username, and password in the connection string.
50
-
2. From the project root folder open command prompt and run `dotnet update`, `dotnet build`, and `dotnet run`. These commands will update NuGet packages, build project, and run web app. As an alternative,
49
+
1. Clone this repository using [Git for Windows](http://www.git-scm.com/), or download the zip file, if you have not done it.
50
+
2. Open appsettings.json file in the root of the folder and change server, database, username, and password in the connection string.
51
+
3. From the project root folder open command prompt and run `dotnet update`, `dotnet build`, and `dotnet run`. These commands will update NuGet packages, build project, and run web app. As an alternative,
51
52
open project using Visual Studio 2015 U3, or Visual Studio Code, compile and run sample.
52
53
53
54
<aname=sample-details></a>
54
55
55
56
This sample demonstrates how SQL Server 2017 analyzes workload, keep track about the last good
56
-
plan that successfully executed the query, and reverts regressed plan if it is worse that the last known good plan.
57
+
plan that successfully executed the query in the past, and reverts regressed plan if it is worse that the last known good plan.
57
58
The following query is used to demonstrate plan regression and correction:
58
59
59
60
```
@@ -72,7 +73,7 @@ Open **demo-full.sql** and follow the comments in the code. Here is the short ex
72
73
- Execute query `EXEC dbo.regression` to cause the regression.
73
74
- Execute query `EXEC dbo.report 7` 20 times and verify that the execution is slower.
74
75
- Query `sys.dm_db_tuning_recommendations` and verify that regression is detected and that
75
-
the correction script is in the view. You can use the following query:
76
+
the correction script is in the view. Since some information are formatted as JSON docuemnts, you can use the following query to extract relevant information:
76
77
77
78
```
78
79
SELECT planForceDetails.query_id, reason, score,
@@ -94,7 +95,7 @@ Fig. 1. Optimal plan with "Hash Aggregate".
- Take the script from the `sys.dm_db_tuning_recommendations` view and force the recommended plan.
98
+
- Take the correction script from the `sys.dm_db_tuning_recommendations` view and force the recommended plan.
98
99
- Execute query `EXEC dbo.report 7` 20 times and verify that the execution is faster. Open Query Store UI in SSMS (e.g. "Top Resource Consuming Queries"), find the query, verify that the plan is forced and that the regression is fixed.
99
100
100
101
#### Part II - Automatic tuning
@@ -134,13 +135,14 @@ After some time, you will notice that the regression will be automatically corre
134
135
<aname=disclaimers></a>
135
136
136
137
## Disclaimers
137
-
The code included in this sample is not intended to be a set of best practices on how to build scalable enterprise grade applications. This is beyond the scope of this quick start sample.
138
+
The code included in this sample is not intended to be a set of best practices on how to build scalable enterprise grade applications. This is beyond the scope of this sample.
138
139
139
140
<aname=related-links></a>
140
141
141
142
## Related Links
142
143
143
-
-[Automatic tuning in SQL Server 2017 CTP2.0+] (https://docs.microsoft.com/sql/relational-databases/automatic-tuning/automatic-tuning)
144
-
-[Monitoring Performance By Using the Query Store] (https://docs.microsoft.com/en-us/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store)
144
+
-[Automatic tuning in SQL Server 2017 CTP2.0+](https://docs.microsoft.com/sql/relational-databases/automatic-tuning/automatic-tuning)
-[Monitoring Performance By Using the Query Store](https://docs.microsoft.com/en-us/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store)
0 commit comments