Creates a user-defined optimization goal, and defines the set of active criteria included in the goal.
sp_optgoal 'goal_name’, action
show | null | no action – displays the contents of the goal.
save – creates new goal or updates and existing goal.
delete – deletes the goal.
SET PLAN OPTLEVEL ase_current SET PLAN OPTGOAL allrows_mix SET HASH_JOIN 1
sp_optgoal 'goal_1', 'save'
set plan optgoal goal_1
sp_configure "optimization goal", 1, "goal_1"
sp_optgoal 'goal_1', 'delete'
sp_optgoal with no parameters displays a list of all user-defined optimizer goals.
The permission checks for sp_optgoal differ based on your granular permissions settings.
Setting | Description |
---|---|
Enabled | With granular permissions enabled, users with sa_role and sa_serverprivs_role must have manage opt goal privilege to create or delete a goal. By default, sa_role and sa_serverprivs_role are granted the manage opt goal privilege. Once created, all users can use the goal. Any user can run sp_optgoal 'show'. |
Disabled | With granular permissions disabled, you must be a user with sa_role to create or delete a goal. However, once created, all users can use the goal. Any user can run sp_optgoal 'show'. |
Values in event and extrainfo columns from the sysaudits table are:
Information | Values |
---|---|
Event | 38 |
Audit option | exec_procedure |
Command or access audited | Execution of a procedure |
Information in extrainfo |
|