{ "schemaVersion": "1.0", "version": "0.2", "name": "Custom Checks Ruleset", "rules":[ { "target": { "type": "Database", "platform": "/^(Windows|Linux)$/", "engineEdition": "OnPremises, ManagedInstance" }, "id": "Custom_AutoCreateStats", "itemType": "definition", "tags": [ "CustomRuleset", "Performance", "Statistics", "QueryOptimizer" ], "displayName": "Auto-Create Statistics should be on", "description": "The Query Optimizer determines whether an index is useful for a specific query by evaluating the stored statistics. If the statistics become out of date and significant changes have occurred against the underlying data, this can result in less than optimal query performance. In most cases, it's best to let SQL Server maintain the statistics. If you turn 'Auto Create Stats' and 'Auto Update Stats' off, then it is up to you to keep the statistics up-to-date somehow. Failure to do so will lead to poor query performance. Most applications should have these options ON.\n \n When the Auto Create statistics setting is ON, the Query Optimizer creates statistics on one or more columns of a table or an indexed view, as necessary, to improve query plans and query performance.", "message": "Turn Auto-Create Statistics option on to improve query performance.", "helpLink": "https://docs.microsoft.com/sql/relational-databases/statistics/statistics#CreateStatistics", "probes": [ "Custom_DatabaseConfiguration" ], "condition": "@is_auto_create_stats_on" }, { "target": { "type": "Server", "platform": "/^(Windows|Linux)$/", "engineEdition": "OnPremises" }, "id": "Custom_TF834", "itemType": "definition", "tags": [ "CustomRuleset", "TraceFlag", "Performance", "Memory", "ColumnStore" ], "displayName": "TF 834 enables large-page allocations", "description": "Trace Flag 834 causes the server to use large-page memory (LPM) model for the buffer pool allocations. Consider enabling TF 834 if you have a server that has a lot of memory, particularly for an analytical or data warehousing workload. Trace flag 834 is NOT recommended on SQL Server instances that use columnstore indexes.", "message": "Enable trace flag 834 to use large-page allocations to improve analytical and data warehousing workloads.", "helpLink": "https://support.microsoft.com/help/4465518", "level": "Information", "probes": [ "Custom_EnabledGlobalTraceFlags" ], "condition": { "in": [ 834, "@TraceFlag" ] } }, { "id": "Custom_TF834", "itemType": "override", "targetFilter": { "version": "(,11.0)" }, "description": "Trace Flag 834 causes the server to use large-page memory (LPM) model for the buffer pool allocations. Consider enabling TF 834 if you have a server that has a lot of memory, particularly for an analytical or data warehousing workload.", "message": "Consider enabling trace flag 834 to use large-page allocations to improve analytical and data warehousing workloads.", "helpLink": "https://support.microsoft.com/help/2964518" } ], "probes":{ "Custom_DatabaseConfiguration": [ { "type": "SQL", "target": { "type": "Database", "version": "(,12.0)", "platform": "/^(Windows|Linux)$/", "engineEdition": "OnPremises, ManagedInstance" }, "implementation": { "query": "SELECT db.is_auto_create_stats_on, db.is_auto_update_stats_on, 0 AS query_store_state, db.collation_name, (SELECT collation_name FROM master.sys.databases (NOLOCK) WHERE database_id = 1) AS master_collation, db.is_auto_close_on, db.is_auto_shrink_on, db.page_verify_option, db.is_db_chaining_on, NULL AS is_auto_create_stats_incremental_on, db.is_trustworthy_on, db.is_parameterization_forced FROM [sys].[databases] (NOLOCK) AS db WHERE db.[name]=@TargetName" } }, { "type": "SQL", "target": { "type": "Database", "version": "[12.0, 13.0)", "platform": "/^(Windows|Linux)$/", "engineEdition": "OnPremises, ManagedInstance" }, "implementation": { "query": "SELECT db.is_auto_create_stats_on, db.is_auto_update_stats_on, 0 AS query_store_state, db.collation_name, (SELECT collation_name FROM master.sys.databases (NOLOCK) WHERE database_id = 1) AS master_collation, db.is_auto_close_on, db.is_auto_shrink_on, db.page_verify_option, db.is_db_chaining_on, db.is_auto_create_stats_incremental_on, db.is_trustworthy_on, db.is_parameterization_forced FROM [sys].[databases] (NOLOCK) AS db WHERE db.[name]=@TargetName" } }, { "type": "SQL", "target": { "type": "Database", "version": "[13.0,)", "platform": "/^(Windows|Linux)$/", "engineEdition": "OnPremises, ManagedInstance" }, "implementation": { "useDatabase": true, "query": "SELECT db.is_auto_create_stats_on, db.is_auto_update_stats_on, (SELECT CAST(actual_state AS DECIMAL) FROM [sys].[database_query_store_options]) AS query_store_state, db.collation_name, (SELECT collation_name FROM master.sys.databases (NOLOCK) WHERE database_id = 1) AS master_collation, db.is_auto_close_on, db.is_auto_shrink_on, db.page_verify_option, db.is_db_chaining_on, db.is_auto_create_stats_incremental_on, db.is_trustworthy_on, db.is_parameterization_forced FROM [sys].[databases] (NOLOCK) AS db WHERE db.[name]=@TargetName" } } ], "Custom_EnabledGlobalTraceFlags": [ { "type": "SQL", "target": { "type": "Server", "engineEdition": "OnPremises, ManagedInstance" }, "implementation": { "query": "DECLARE @tracestatus TABLE (TraceFlag NVARCHAR(40), [Status] tinyint, [Global] tinyint, [Session] tinyint); INSERT INTO @tracestatus EXEC ('DBCC TRACESTATUS WITH NO_INFOMSGS'); IF NOT EXISTS(SELECT * FROM @tracestatus WHERE Global=1) SELECT 0 AS [TraceFlag], 0 AS [Status] ELSE SELECT [TraceFlag], [Status] FROM @tracestatus WHERE Global=1", "transform": { "type": "aggregate", "map": { "TraceFlag": "array" } } } } ] } }