Skip to content

Commit d43db92

Browse files
author
pmasl
committed
Adding demos
Auto tuning and Query Tuning Assistant
1 parent 3f74b01 commit d43db92

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
This is a repro package to demonstrate the Automatic Tuning (Auto Plan Correction) in SQL Server 2017.
2+
This feature is using telemtry from the Query Store feature we launched with Azure SQL Database and SQL Server 2016 to provide built-in intelligence.
3+
4+
This repro assumes the following:
5+
6+
- SQL Server 2017 installed (pick at minimum Database Engine) on Windows. This feature requires Developer or Enterprise Edition.
7+
- You have installed SQL Server Management Studio or SQL Operations Studio (https://docs.microsoft.com/en-us/sql/sql-operations-studio/download)
8+
- You have downloaded the RML Utilities from https://www.microsoft.com/en-us/download/details.aspx?id=4511.
9+
- These demos use a named instance called SQL2017. You will need to edit the .cmd scripts which connect to SQL Server to change to a default instance or whatever named instance you have installed.
10+
11+
0. Install ostress from the package RML_Setup_AMD64.msi. Add C:\Program Files\Microsoft Corporation\RMLUtils to your path.
12+
13+
1. Restore the WideWorldImporters database backup to your SQL Server 2017 instance. The WideWorldImporters can be found in https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/wide-world-importers
14+
15+
2. Run Scenario.cmd to customize the WideWorldImporters database and start the demo. Leave it running...
16+
17+
3. Setup Performance Monitor on Windows to track SQL Statistics/Batch Requests/sec
18+
19+
4. While Scenario.cmd is running, run Regression.cmd (you may need to run this a few times for timing reasons). Notice the drop in batch requests/sec which shows a performance regression in your workload.
20+
21+
5. Load recommendations.sql into SQL Server Management Studio or SQL Operations Studio and review the results. Notice the time difference under the reason column and value of state_transition_reason which should be AutomaticTuningOptionNotEnabled. This means we found a regression but are recommending it only, not automatically fixing it. The script column shows a query that could be used to fix the problem.
22+
23+
6. Stop Scenario.cmd workload by pressing CTRL+C, and then choose "N" when prompted to terminate the batch.
24+
25+
7. Now let's see what happens with automatic plan correction which uses this command in SQL Server 2017:
26+
27+
ALTER DATABASE <db>
28+
SET AUTOMATIC_TUNING ( FORCE_LAST_GOOD_PLAN = ON )
29+
30+
8. Run Auto_tune.cmd which uses the above command to set automatic plan correct ON for WideWorldImporters, and starts same workload as Scenario.cmd
31+
32+
9. Repeat steps 4-6 as above. In Performance Monitor you will see the batch requests/sec dip but within a second go right back up. This is because SQL Server detected the regression and automatically reverted to "last known good" or the last known good query plan as found in the Query Store. Note in the output of recommendations.sql the state_transition_reason now says LastGoodPlanForced.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
This is a repro package to demonstrate how to upgrade a database compatibility level using Query Tuning Assistant.
2+
This feature is using telemtry from the Query Store feature we launched with Azure SQL Database and SQL Server 2016 to detect upgrade-related regressions.
3+
4+
This repro assumes the following:
5+
6+
- SQL Server 2016+ installed (pick at minimum Database Engine) on Windows.
7+
- You have installed SQL Server Management Studio v18
8+
- You have downloaded the RML Utilities from https://www.microsoft.com/en-us/download/details.aspx?id=4511.
9+
- These demos use a named instance called SQL2017. You will need to edit the .cmd scripts which connect to SQL Server to change to a default instance or whatever named instance you have installed.
10+
11+
0. Install ostress from the package RML_Setup_AMD64.msi. Add C:\Program Files\Microsoft Corporation\RMLUtils to your path.
12+
13+
1. Attach the AdventureWorksDW2012 database to your SQL Server 2016+ instance. The adventure-works-2012-dw-data-file.mdf is provided in https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks2012
14+
15+
3. Start QTA following instructions in https://docs.microsoft.com/en-us/sql/relational-databases/performance/upgrade-dbcompat-using-qta.
16+
17+
4. When requested to run a baseline collection, run PreUpgrade.cmd to customize the AdventureWorksDW2012 database and start the demo. Run it to completion...
18+
19+
5. After its completed, continue QTA workflow.
20+
21+
6. When requested to re-run the same workload, run PostUpgrade.cmd. Run it to completion...
22+
23+
7. After its completed, continue QTA workflow.

0 commit comments

Comments
 (0)