SQL Server Monitoring – Plan guides

This blog is part of the blog series named SQL Server Monitoring.

Purpose

To show the configured plan guides.

Report

The report has a table showing each configured plan guide.

Sources

This feature queries the DMV sys.plan_guides which returns information for existing plan guides.

Model

The model for the report uses the fact [Plan guides] and the dimension [Database].

Service setup

The feature uses the service ‘fhsmSPPlanGuides’ which can be configured using the stored procedure fhsmSPControl.

Parameter

The feature accept the parameter @Databases and the syntax is the same that is used in the SQL Server Index and Statistics Management solution made by Ola Hallengren.

The default parameter for the feature is “@Databases = ‘USER_DATABASES, msdb'”

ValueDescription
SYSTEM_DATABASESAll system databases (master, msdb, model, and tempdb)
USER_DATABASESAll user databases
ALL_DATABASESAll databases
Db1The database Db1
Db1, Db2The databases Db1 and Db2
USER_DATABASES, -Db1All user databases, except Db1
%Db%All databases that have “Db” in the name
%Db%, -Db1All databases that have “Db” in the name, except Db1
ALL_DATABASES, -%Db%All databases that do not have “Db” in the name
EXEC fhsmSPControl
	@Type = 'Parameter',
	@Command = 'list',
	@Task = 'fhsmSPPlanGuides',
	@Name = 'Plan guides',
	@Wildcard = 0;

EXEC fhsmSPControl
	@Type = 'Parameter',
	@Command = 'set',
	@Task = 'fhsmSPPlanGuides',
	@Name = 'Plan guides',
	@Parameter = '@Databases = ''USER_DATABASES, msdb''';

Schedule

The default schedule for the feature is every hour (3.600 seconds).

EXEC fhsmSPControl
	@Type = 'Schedule',
	@Command = 'list',
	@Task = 'fhsmSPPlanGuides',
	@Name = 'Plan guides',
	@Wildcard = 0;

EXEC fhsmSPControl
	@Type = 'Schedule',
	@Command = 'set',
	@Task = 'fhsmSPPlanGuides',
	@Name = 'Plan guides',
	@ScheduleType = 0,
	@Enabled = 1,
	@ExecutionDelaySec = 3600,
	@FromTime = '00:00:00',
	@ToTime = '23:59:59',
	@Monday = 1,
	@Tuesday = 1,
	@Wednesday = 1,
	@Thursday = 1,
	@Friday = 1,
	@Saturday = 1,
	@Sunday = 1;

Retention

The default retention for the table dbo.fhsmPlanGuides is 90 days.

EXEC fhsmSPControl
	@Type = 'Retention',
	@Command = 'list',
	@TableName = 'fhsmPlanGuides',
	@Wildcard = 0;

EXEC fhsmSPControl
	@Type = 'Retention',
	@Command = 'set',
	@TableName = 'fhsmPlanGuides',
	@Enabled = 1,
	@Sequence = 1,
	@Days = 90;