top of page

CRM 2015 – ExecuteMultiple to improve performance for bulk data load

Sometimes we need to do some bulk import, in here i don’t want to discuss what approach is better to use, Custom Code? Third Party Applications, SSIS,.. what i want to show in here is that from some tests i have done on importing lots of records is that much more the records to create, until reach the maximum possible (for this please go to the link at the end of the post), the time taken from the two ways that i tested is more visible. In terms of that, i put in here 3 tests and the results (rough values): 100 Records Execute :20.000 ms ExecuteMultipleRequest: 16.000ms Something around 23% more time. 500 Records Execute :92.000 ms ExecuteMultipleRequest: 73.500ms Something around 25% more time. 1000 Records Execute :180.000 ms ExecuteMultipleRequest: 142.500ms Something around 26% more time.

Applies To: CRM 2015 on-prem, CRM Online

You can use the ExecuteMultipleRequest message to support higher throughput bulk message passing scenarios in Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online 2015 Update, particularly in the case of Microsoft Dynamics CRM Online where Internet latency can be the largest limiting factor. ExecuteMultipleRequest accepts an input collection of message Requests, executes each of the message requests in the order they appear in the input collection, and optionally returns a collection of Responses containing each message’s response or the error that occurred. Each message request in the input collection is processed in a separate database transaction. ExecuteMultipleRequest is executed by using the IOrganizationService.Execute method. In general, ExecuteMultipleRequest behaves the same as if you executed each message request in the input request collection separately, except with better performance. Use of the CallerId parameter of the service proxy is honored and will apply to the execution of every message in the input request collection. Plug-ins and workflow activities are executed as you would expect for each message processed. Custom code in the form of plug-ins and custom workflow activities can even execute ExecuteMultipleRequest. However, there are a few key points to keep in mind. An exception thrown by a synchronous registered plug-in is returned in the response collection item Fault parameter. If a plug-in executes within a database transaction, the plug-in executes ExecuteMultipleRequest, and a transaction rollback is initiated, the rollback includes any data changes resulting from requests executed by ExecuteMultipleRequest. The code from the CRM SDk. // Get a reference to the organization service. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials)) { // Enable early-bound type support to add/update entity records required for this sample. _serviceProxy.EnableProxyTypes(); #region Execute Multiple with Results // Create an ExecuteMultipleRequest object. requestWithResults = new ExecuteMultipleRequest() { // Assign settings that define execution behavior: continue on error, return responses. Settings = new ExecuteMultipleSettings() { ContinueOnError = false, ReturnResponses = true }, // Create an empty organization request collection. Requests = new OrganizationRequestCollection() }; // Create several (local, in memory) entities in a collection. EntityCollection input = GetCollectionOfEntitiesToCreate(); // Add a CreateRequest for each entity to the request collection. foreach (var entity in input.Entities) { CreateRequest createRequest = new CreateRequest { Target = entity }; requestWithResults.Requests.Add(createRequest); } // Execute all the requests in the request collection using a single web method call. ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)_serviceProxy.Execute(requestWithResults); // Display the results returned in the responses. foreach (var responseItem in responseWithResults.Responses) { // A valid response. if (responseItem.Response != null) DisplayResponse(requestWithResults.Requests, responseItem.Response); // An error has occurred. else if (responseItem.Fault != null) DisplayFault(requestWithResults.Requests, responseItem.RequestIndex, responseItem.Fault); }

Link to the Microsoft Site:

2 views0 comments

Recent Posts

See All


bottom of page