Microsoft Dynamics CRM 2011 – Best Development Practices (Performance Best Practices)

This blog describes best practices for customizing Microsoft Dynamics CRM 2011. The following best practices will help in writing code that performs better.

Use Common Methods:

The common methods are faster than using the Execute method with the corresponding message. These common methods are: Create, Delete, Update, Retrieve and RetrieveMultiple. Their corresponding messages are CreateRequest, DeleteRequest, UpdateRequest, RetrieveRequest and RetrieveMultipleRequest.

Use Early Bound Types:

The Entity class is useful for when your code needs to work on entities and attributes that are not known at the time the code is written. However, this flexibility comes at a price because you will not have any compile time verification of entity and attribute names. If your entities are already defined at code time, you should use the early bound types that you can generate by using the CrmSvcUtil tool. Early Bound programming in Visual Studio 2010 will have advantage of intellisense and compile time verification.

Write Plug-ins That Execute Faster:

Always write a plug-in that takes the least amount of time to perform its intended task. For example, the Execute method is processed frequently in Microsoft Dynamics CRM. If you register a plug-in on that message, your plug-in could have a significant performance impact on the system because it will execute every time the Execute method is processed, which happens very frequently.

Limit Data Retrieved:

When using the methods that retrieve data from the server, only retrieve the minimum amount of data needed by your application. This is done by specifying the column set, which is the set of entity attributes to retrieve. For example, it is rarely advisable to retrieve all the metadata with the RetrieveAllEntitiesRequest message, specifying the EntityFilters. Instead, you will get better performance if you restrict the entity filter, or use one of the following messages: RetrieveEntityRequest, RetrieveOptionSetRequest, RetrieveAttributeRequest or RetrieveRelationshipRequest.

Limit Operations That Cascade to Related Entities:

When using the Update method or UpdateRequest message, do not set the OwnerId attribute on a record unless the owner has actually changed. Setting this attribute often requires changes to cascade to related entities, increasing the amount of time required for the update operation.


To improve performance on requests to the web services, you can statically cache the IServiceConfiguration class. For multi-threaded applications, the cached object is not thread safe. If your application makes use of the metadata, it is recommended that you cache the metadata you have retrieved and to periodically call the RetrieveTimestampRequest message to determine if you need to refresh the cache.

My above blog is based on and is a summary of Best Practices guidelines given by Microsoft.

I hope this blog about ‘Microsoft Dynamics CRM 2011 – Best Development Practices (Performance Best Practices)’ was informative. Please feel free to leave your comments.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: