-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Optimize for Ad-Hoc Workloads should be Enabled.sql
- Loading branch information
1 parent
bcadbb9
commit eee3e23
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
SQLChecks/Optimize for Ad-Hoc Workloads should be Enabled.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
DECLARE | ||
@AdditionalInfo AS XML , | ||
@AdhocRatio AS DECIMAL(3,2) , | ||
@OptimizeForAdhocWorkloads AS BIT; | ||
|
||
SELECT | ||
@AdhocRatio = CAST (SUM (CASE WHEN objtype = N'Adhoc' AND usecounts = 1 THEN CAST (size_in_bytes AS DECIMAL(19,2)) ELSE 0 END) / SUM (CAST (size_in_bytes AS DECIMAL(19,2))) AS DECIMAL(3,2)) | ||
FROM | ||
sys.dm_exec_cached_plans; | ||
|
||
SELECT | ||
@OptimizeForAdhocWorkloads = CAST (value_in_use AS BIT) | ||
FROM | ||
sys.configurations | ||
WHERE | ||
[name] = N'optimize for ad hoc workloads'; | ||
|
||
INSERT INTO | ||
#Checks | ||
( | ||
CheckId , | ||
Title , | ||
RequiresAttention , | ||
CurrentStateImpact , | ||
RecommendationEffort , | ||
RecommendationRisk , | ||
AdditionalInfo | ||
) | ||
SELECT | ||
CheckId = {CheckId} , | ||
Title = N'{CheckTitle}' , | ||
RequiresAttention = | ||
CASE | ||
WHEN @AdditionalInfo IS NULL | ||
THEN 0 | ||
ELSE | ||
1 | ||
END , | ||
CurrentStateImpact = 1 , -- Low | ||
RecommendationEffort = 1 , -- Low | ||
RecommendationRisk = 1 , -- Low | ||
AdditionalInfo = @AdditionalInfo; |