ERMO = 0
This should be the most commonly used setting for optimal performance. This setting allows you to take advantage of the various sub-settings that will be discussed in upcoming posts. We define this as the best setting to use when you have a wide variety of visibility counts between users, but in general it should be used in most situations. One example of a query when ERMO is set to 0 is below, but please note that this is not all inclusive since various sub-settings can further alter the query here.
WITH"activitypointer0Security" as (
selectSubjectas"Subject",PriorityCodeas"PriorityCode",RegardingObjectIdas"RegardingObjectId",ActivityTypeCodeas"ActivityTypeCode",StateCodeas"StateCode",ScheduledStartas"ScheduledStart",ScheduledEndas"ScheduledEnd",InstanceTypeCodeas"InstanceTypeCode",ActivityIdas"ActivityId",RegardingObjectIdYomiNameas"RegardingObjectIdYomiName",RegardingObjectTypeCodeas"RegardingObjectTypeCode",RegardingObjectIdNameas"RegardingObjectIdName",IsRegularActivityas"IsRegularActivity",OwnerIdas"OwnerId",OwningBusinessUnitas"OwningBusinessUnit",OwningUseras"OwningUser" from [ActivityPointer] as"activitypointer0" where"activitypointer0".OwnerId in(SELECT id fromdbo.fn_GetGuidsFromString(@buIds0))
UNION
selectSubjectas"Subject",PriorityCodeas"PriorityCode",RegardingObjectIdas"RegardingObjectId",ActivityTypeCodeas"ActivityTypeCode",StateCodeas"StateCode",ScheduledStartas"ScheduledStart",ScheduledEndas"ScheduledEnd",InstanceTypeCodeas"InstanceTypeCode",ActivityIdas"ActivityId",RegardingObjectIdYomiNameas"RegardingObjectIdYomiName",RegardingObjectTypeCodeas"RegardingObjectTypeCode",RegardingObjectIdNameas"RegardingObjectIdName",IsRegularActivityas"IsRegularActivity",OwnerIdas"OwnerId",OwningBusinessUnitas"OwningBusinessUnit",OwningUseras"OwningUser" from [ActivityPointer] as"activitypointer0" where"activitypointer0".ActivityId in(selectPOA.ObjectIdfromPrincipalObjectAccess POA WITH (NOLOCK)joinSystemUserPrincipals sup WITH (NOLOCK)onPOA.PrincipalId=sup.PrincipalIdwheresup.SystemUserId= @SystemUserId00 andPOA.ObjectTypeCode= @ObjectTypeCode0 and((POA.AccessRightsMask|POA.InheritedAccessRightsMask)& 1)= 1)
UNION
selectSubjectas"Subject",PriorityCodeas"PriorityCode",RegardingObjectIdas"RegardingObjectId",ActivityTypeCodeas"ActivityTypeCode",StateCodeas"StateCode",ScheduledStartas"ScheduledStart",ScheduledEndas"ScheduledEnd",InstanceTypeCodeas"InstanceTypeCode",ActivityIdas"ActivityId",RegardingObjectIdYomiNameas"RegardingObjectIdYomiName",RegardingObjectTypeCodeas"RegardingObjectTypeCode",RegardingObjectIdNameas"RegardingObjectIdName",IsRegularActivityas"IsRegularActivity",OwnerIdas"OwnerId",OwningBusinessUnitas"OwningBusinessUnit",OwningUseras"OwningUser" from [ActivityPointer] as"activitypointer0" where"activitypointer0".OwningBusinessUnit in(@buId00)
)
select
top 51 "activitypointer0".Subjectas"subject"
,"activitypointer0".PriorityCode as"prioritycode"
,"activitypointer0".RegardingObjectId as"regardingobjectid"
,"activitypointer0".ActivityTypeCode as"activitytypecode"
,"activitypointer0".StateCode as"statecode"
,"activitypointer0".ScheduledStart as"scheduledstart"
,"activitypointer0".ScheduledEnd as"scheduledend"
,"activitypointer0".InstanceTypeCode as"instancetypecode"
,"activitypointer0".ActivityId as"activityid"
,"activitypointer0".RegardingObjectIdYomiName as"regardingobjectidyominame"
,"activitypointer0".RegardingObjectTypeCode as"regardingobjecttypecode"
,"activitypointer0".RegardingObjectIdName as"regardingobjectidname"
,"activitypointerowningusersystemusersystemuserid".InternalEMailAddress as"activitypointerowningusersystemusersystemuserid.internalemailaddress"
from
activitypointer0Security as"activitypointer0" WITH (NOLOCK) leftouterjoinSystemUseras"activitypointerowningusersystemusersystemuserid" WITH (NOLOCK) on ("activitypointer0".OwningUser = "activitypointerowningusersystemusersystemuserid".SystemUserId)
where
(("activitypointer0".IsRegularActivity = @IsRegularActivity0))orderby
"activitypointer0".ScheduledEnd asc
,"activitypointer0".ActivityId asc
ERMO = 1
This setting was considered the most optimal in CRM 4.0, as many of the additional settings we have today were not available. Today we recommend considering this setting when all users have access restricted to just the data they own, and do not have any associated shares. This would generally be a very uncommon scenario.
An example of a query when ERMO is set to 1 is below:
createtable #ObjectsIds(ObjectIduniqueidentifier);
createNONCLUSTEREDindexndx_ObjectsIds_objIdon #ObjectsIds(ObjectIdASC);
insertinto #ObjectsIds
selectPOA.ObjectIdfromPrincipalObjectAccess POA WITH (NOLOCK)joinSystemUserPrincipals sup WITH (NOLOCK)onPOA.PrincipalId=sup.PrincipalIdwheresup.SystemUserId= @SystemUserId0 andPOA.ObjectTypeCode= @ObjectTypeCodeand((POA.AccessRightsMask|POA.InheritedAccessRightsMask)& 1)= 1;
insertinto #ObjectsIds
selectActivityIdfrom [ActivityPointer] WITH (NOLOCK)
whereOwnerIdin
(selectpem.PrincipalIdfromPrincipalEntityMappem WITH (NOLOCK)joinSystemUserPrincipals sup WITH (NOLOCK)onpem.PrincipalId=sup.PrincipalIdwheresup.SystemUserId= @UserIdOwnerCommand0 andpem.ObjectTypeCode= @OtcOwnerCommand0)
insertinto #ObjectsIds
selectActivityIdfrom [ActivityPointer] WITH (NOLOCK)
whereowningbusinessunitin
(selectBusinessUnitIdfromSystemUserBusinessUnitEntityMapWITH (NOLOCK)whereSystemUserId= @SystemUserIdandObjectTypeCode= @ObjectTypeCode)
select
top 51 "activitypointer0".Subjectas"subject"
,"activitypointer0".PriorityCode as"prioritycode"
,"activitypointer0".RegardingObjectId as"regardingobjectid"
,"activitypointer0".ActivityTypeCode as"activitytypecode"
,"activitypointer0".StateCode as"statecode"
,"activitypointer0".ScheduledStart as"scheduledstart"
,"activitypointer0".ScheduledEnd as"scheduledend"
,"activitypointer0".InstanceTypeCode as"instancetypecode"
,"activitypointer0".ActivityId as"activityid"
,"activitypointer0".RegardingObjectIdYomiName as"regardingobjectidyominame"
,"activitypointer0".RegardingObjectTypeCode as"regardingobjecttypecode"
,"activitypointer0".RegardingObjectIdName as"regardingobjectidname"
,"activitypointerowningusersystemusersystemuserid".InternalEMailAddress as"activitypointerowningusersystemusersystemuserid.internalemailaddress"
from
ActivityPointeras"activitypointer0" WITH (NOLOCK) leftouterjoinSystemUseras"activitypointerowningusersystemusersystemuserid" WITH (NOLOCK) on ("activitypointer0".OwningUser = "activitypointerowningusersystemusersystemuserid".SystemUserId)
where
(("activitypointer0".IsRegularActivity = @IsRegularActivity0)and("activitypointer0".ActivityId in(selectdistinctObjectIdfrom #ObjectsIds)))orderby
"activitypointer0".ScheduledEnd asc
,"activitypointer0".ActivityId asc;
droptable #ObjectsIds
ERMO = 2
This was considered the optimal setting in CRM 2011 pre-UR10. This setting would be considered today when all users have visibility to a large amount of records, while being associated with a very small amount of Principals and Business Units. This would be another edge scenario.
An example of a query when ERMO is set to 2 is below:
select
top 51 "activitypointer0".Subjectas"subject"
,"activitypointer0".PriorityCode as"prioritycode"
,"activitypointer0".RegardingObjectId as"regardingobjectid"
,"activitypointer0".ActivityTypeCode as"activitytypecode"
,"activitypointer0".StateCode as"statecode"
,"activitypointer0".ScheduledStart as"scheduledstart"
,"activitypointer0".ScheduledEnd as"scheduledend"
,"activitypointer0".InstanceTypeCode as"instancetypecode"
,"activitypointer0".ActivityId as"activityid"
,"activitypointer0".RegardingObjectIdYomiName as"regardingobjectidyominame"
,"activitypointer0".RegardingObjectTypeCode as"regardingobjecttypecode"
,"activitypointer0".RegardingObjectIdName as"regardingobjectidname"
,"activitypointerowningusersystemusersystemuserid".InternalEMailAddress as"activitypointerowningusersystemusersystemuserid.internalemailaddress"
from
ActivityPointeras"activitypointer0" WITH (NOLOCK) leftouterjoinSystemUseras"activitypointerowningusersystemusersystemuserid" WITH (NOLOCK) on ("activitypointer0".OwningUser = "activitypointerowningusersystemusersystemuserid".SystemUserId)
where
(("activitypointer0".IsRegularActivity = @IsRegularActivity0)and("activitypointer0".OwnerId in(SELECT id fromdbo.fn_GetGuidsFromString(@buIds0))
or"activitypointer0".ActivityId in(selectPOA.ObjectIdfromPrincipalObjectAccess POA
WITH (NOLOCK)wherePOA.PrincipalIdin(@userPrincipalPOA00,@userPrincipalTeamPOA00,@userPrincipalTeamPOA1100,@userPrincipalTeamPOA2100,userPrincipalTeamPOA3100,@userPrincipalTeamPOA4100,@userPrincipalTeamPOA538,@userPrincipalTeamPOA610,@userPrincipalTeamPOA710,@userPrincipalTeamPOA810,@userPrincipalTeamPOA910,@userPrincipalTeamPOA1010,@userPrincipalTeamPOA1110,@userPrincipalTeamPOA1210,@userPrincipalTeamPOA1310,@userPrincipalTeamPOA1410,@userPrincipalTeamPOA1510,@userPrincipalTeamPOA1610,etc.etc.)andPOA.ObjectTypeCode= @ObjectTypeCode0 and((POA.AccessRightsMask|POA.InheritedAccessRightsMask)& 1)= 1)
or"activitypointer0".OwningBusinessUnit in(@buId00)
))orderby
"activitypointer0".ScheduledEnd asc
,"activitypointer0".ActivityId asc
ERMO = 3
This is a rarely used, and scarcely documented setting that is generally meant to be implemented only for performance and functional comparisons. It would be considered optimal in environments where SQL memory is concerning, and all table row counts are small.
An example of a query when ERMO is set to 3 is below:
select
top 51 "activitypointer0".Subjectas"subject"
,"activitypointer0".PriorityCode as"prioritycode"
,"activitypointer0".RegardingObjectId as"regardingobjectid"
,"activitypointer0".ActivityTypeCode as"activitytypecode"
,"activitypointer0".StateCode as"statecode"
,"activitypointer0".ScheduledStart as"scheduledstart"
,"activitypointer0".ScheduledEnd as"scheduledend"
,"activitypointer0".InstanceTypeCode as"instancetypecode"
,"activitypointer0".ActivityId as"activityid"
,"activitypointer0".RegardingObjectIdYomiName as"regardingobjectidyominame"
,"activitypointer0".RegardingObjectTypeCode as"regardingobjecttypecode"
,"activitypointer0".RegardingObjectIdName as"regardingobjectidname"
,"activitypointerowningusersystemusersystemuserid".InternalEMailAddress as"activitypointerowningusersystemusersystemuserid.internalemailaddress"
from
ActivityPointeras"activitypointer0" WITH (NOLOCK) leftouterjoinSystemUseras"activitypointerowningusersystemusersystemuserid" WITH (NOLOCK) on ("activitypointer0".OwningUser = "activitypointerowningusersystemusersystemuserid".SystemUserId)
where
(("activitypointer0".IsRegularActivity = @IsRegularActivity0)and("activitypointer0".OwnerId in(selectpem.PrincipalIdfromPrincipalEntityMappem WITH (NOLOCK)joinSystemUserPrincipals sup WITH (NOLOCK)onpem.PrincipalId=sup.PrincipalIdwheresup.SystemUserId= @UserIdOwnerCommand00 andpem.ObjectTypeCode= @OtcOwnerCommand00)
or"activitypointer0".ActivityId in(selectPOA.ObjectIdfromPrincipalObjectAccess POA WITH (NOLOCK)joinSystemUserPrincipals sup WITH (NOLOCK)onPOA.PrincipalId=sup.PrincipalIdwheresup.SystemUserId= @SystemUserId00 andPOA.ObjectTypeCode= @ObjectTypeCode0 and((POA.AccessRightsMask|POA.InheritedAccessRightsMask)& 1)= 1)or"activitypointer0".OwningBusinessUnit in(selectBusinessUnitIdfromSystemUserBusinessUnitEntityMapWITH (NOLOCK)whereSystemUserId= @SystemUserId0 andObjectTypeCode= @ObjectTypeCode1)))orderby
"activitypointer0".ScheduledEnd asc
,"activitypointer0".ActivityId asc