@@ -9,7 +9,7 @@ EXEC [dbo].[initialize]
9
9
* Plan regression identification.
10
10
********************************************************/
11
11
12
- -- 1. Start workload - execute procedure 30 times:
12
+ -- 1. Start workload - execute procedure 30-300 times:
13
13
begin
14
14
declare @packagetypeid int = 7 ;
15
15
exec dbo .report @packagetypeid
@@ -34,15 +34,16 @@ go 20
34
34
35
35
-- 4. Find recommendation recommended by database:
36
36
SELECT planForceDetails .query_id , reason, score,
37
- JSON_VALUE(details, ' $.implementationDetails.script' ) script,
37
+ JSON_VALUE(details, ' $.implementationDetails.script' ) [correction script] ,
38
38
planForceDetails.[new plan_id], planForceDetails.[recommended plan_id]
39
39
FROM sys .dm_db_tuning_recommendations
40
40
CROSS APPLY OPENJSON (Details, ' $.planForceDetails' )
41
41
WITH ( [query_id] int ' $.queryId' ,
42
42
[new plan_id] int ' $.regressedPlanId' ,
43
- [recommended plan_id] int ' $.forcedPlanId '
43
+ [recommended plan_id] int ' $.recommendedPlanId '
44
44
) as planForceDetails;
45
45
46
+
46
47
-- Note: User can apply script and force the recommended plan to correct the error.
47
48
<< Insert T- SQL from the script column here and execute the script>>
48
49
-- e.g.: exec sp_query_store_force_plan @query_id = 3, @plan_id = 1
66
67
/* *******************************************************
67
68
* RESET - clear everything
68
69
********************************************************/
69
- EXEC [dbo].[initialize]
70
+ EXEC [dbo].[initialize];
70
71
71
72
-- Enable automatic tuning on the database:
72
73
ALTER DATABASE current
@@ -77,20 +78,20 @@ SELECT name, desired_state_desc, actual_state_desc, reason_desc
77
78
FROM sys .database_automatic_tuning_options ;
78
79
79
80
80
- -- 1. Start workload - execute procedure 20 times like in the phase I
81
+ -- 1. Start workload - execute procedure 30-300 times like in the phase I
81
82
begin
82
83
declare @packagetypeid int = 7 ;
83
84
exec dbo .report @packagetypeid
84
85
end
85
86
go 300
86
87
87
88
-- 2. Execute the procedure that causes plan regression
88
- exec dbo .regression
89
+ exec dbo .regression ;
89
90
90
91
-- 3. Start workload again - verify that it is slower.
91
92
begin
92
93
declare @packagetypeid int = 7 ;
93
- exec dbo .report @packagetypeid
94
+ exec dbo .report @packagetypeid;
94
95
end
95
96
go 20
96
97
@@ -105,7 +106,7 @@ FROM sys.dm_db_tuning_recommendations
105
106
CROSS APPLY OPENJSON (Details, ' $.planForceDetails' )
106
107
WITH ( [query_id] int ' $.queryId' ,
107
108
[new plan_id] int ' $.regressedPlanId' ,
108
- [recommended plan_id] int ' $.forcedPlanId '
109
+ [recommended plan_id] int ' $.recommendedPlanId '
109
110
) as planForceDetails;
110
111
111
112
0 commit comments