Blog
Microsoft Dynamics CRM 2011 performance – Coding methods
There are multiple methods to coding when adding or retrieving data, but some methods are better than others when it comes to performance. Below are some coding methods which are defined within the SDK that you should consider when coding your custom processes and applications for optimal Dynamics CRM 2011 performance.
ExecuteMultipleRequest
Within the SDK of the CRM 2011 UR12 release, MS has provided a new message called ExecuteMultipleRequest as part of the Execute method. It allows you to batch process unrelated requests such as create or update. This can dramatically improve performance in your process or application since it reduces the number of interactions to the CRM server by processing your requests as a collection rather than processing each request one by one. The new ExecuteMultipleRequest message feature can also be useful for getting around the 2 minute time limit when working within the Sandbox in CRM Online, depending on the scenario. However, some limitations with CRM Online are that there is a maximum batch size of 1000 and the maximum number of concurrent executions is 2 for each organization. If either of these limits have exceeded, a fault is thrown which you can catch in your code and work around it as you see fit. For example, if a fault is thrown due to the batch size limit exceeded, you can resize the request collection to be within the limit and have it reprocess the batch.
RelatedEntities
Another feature within the CRM 2011 SDK which can help facilitate with reducing the back and forth calls to the CRM server is the RelatedEntities property when doing creates or updates of related entities. When using the RelatedEntities property, you specify the primary and related entities you want to create/update and the relationship name that links them together. This helps reduce code and is efficient since it will process both primary and related data in the same transaction rather than processing them separately.
FetchXML Aggregation
Lastly, I want to mention FetchXml queries. For optimal performance, FetchXML queries should be used when you want to get a count, sum, avg, etc. as opposed to looping through the records using the RetrieveMultiple request. Some limitations of FetchXML include a 5,000 record limit for CRM Online and you can only specify one aggregate per query.
To read more about these methods and find examples, download the latest CRM 2011 SDK at:
http://www.microsoft.com/en-us/download/details.aspx?id=24004
You can contact us at [email protected], 856-910-7771.