{"id":38,"date":"2013-02-05T09:49:00","date_gmt":"2013-02-05T04:19:00","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=38"},"modified":"2013-02-05T09:49:00","modified_gmt":"2013-02-05T04:19:00","slug":"use-executemultiplerequest-for-performance-improvement-in-bulk-data-load-and-other-operations","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2013\/02\/use-executemultiplerequest-for-performance-improvement-in-bulk-data-load-and-other-operations\/","title":{"rendered":"Use ExecuteMultipleRequest for performance improvement in bulk data load and other operations"},"content":{"rendered":"<div dir=\"ltr\" trbidi=\"on\"><\/p>\n<div><span>\u00a0A new request called <b>ExecuteMultipleRequest<\/b> has been added to the Update rollup 12 for the <b>Bulk Data Load<\/b>. Using this request, multiple request can be executed with the single server call. The main advantage of this request is that it will definitely improve the performance since in one round trip to the server, it actually posts more than 1 message to be executed. With reduced round trips for each individual request the performance improvement is exponential. <\/p>\n<p><\/span><\/div>\n<p><\/p>\n<div><span>ExecuteMultipleRequest accepts the collection of different request and executes each request in a order they appear in the collection. This request will optionally returns the response of each request or error occurred while executing the request. Each message request in the input collection is processed in a separate database transaction. <\/p>\n<p><\/span><\/div>\n<p><\/p>\n<div><span>Members of ExecuteMultipleRequest:<\/p>\n<p><\/span><\/div>\n<p><\/p>\n<div><span><span>1.<span>\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Requests: It is a collection of message requests to execute. <\/p>\n<p><\/span><\/div>\n<p><\/p>\n<div><span><span>2.<span>\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Settings: It contains settings that define whether execution should continue if an error occurs executing a request and if responses for each message request processed are to be returned.<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>Below is the example, where different requests like Create\/Update are added to <span>ExecuteMultipleRequest collection and submit it for processing in a single round trip.<\/p>\n<p><\/span><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Create an ExecuteMultipleRequest object.<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest()<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Assign settings that define execution behavior: continue on error, return responses. <\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Settings = new ExecuteMultipleSettings()<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ContinueOnError = true,<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ReturnResponses = true<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 },<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Create an empty organization request collection.<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Requests = new OrganizationRequestCollection()<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 };<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/create account entity<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Entity accountEntity=new Entity(&#8220;account&#8221;);<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/set name for the account<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 accountEntity.Attributes[&#8220;name&#8221;] = &#8220;New Account &#8220;+new DateTime();<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/create CreateRequest object<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CreateRequest createRequest = new CreateRequest { Target = accountEntity };<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/add to ExecuteMultipleRequest Collection<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 requestWithResults.Requests.Add(createRequest);<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/retrieve contact entity<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Entity contactEntity = _service.Retrieve(&#8220;contact&#8221;, new Guid(&#8220;FC298C3B-2E4F-\u00a0\u00a0\u00a0\u00a0 E211-9DED-1CC1DE6DAA3E&#8221;), \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new\u00a0Microsoft.Xrm.Sdk.Query.ColumnSet());<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/set Business Phone for the contact<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 contactEntity.Attributes[&#8220;telephone1&#8243;]=&#8221;1234567&#8221;;<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/create UpdateRequest<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UpdateRequest updateRequest = new UpdateRequest { Target = contactEntity };<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/add to ExecuteMultipleRequest Collection<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 requestWithResults.Requests.Add(updateRequest);<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Execute all the requests in the request collection using a single web method call.<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)_service.Execute(requestWithResults);<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (responseWithResults.IsFaulted)<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Display the results returned in the responses.<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 foreach (var responseItem in responseWithResults.Responses)<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ A valid response.<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (responseItem.Response != null) { }<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ An error has occurred.<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (responseItem.Fault != null) { }<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p><\/span><\/div>\n<div><\/div>\n<div><\/div>\n<p><\/p>\n<div><span>Members of ExecuteMultpleResponse:<\/p>\n<p><\/span><\/div>\n<p><\/p>\n<div><span><span>1.<span>\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>IsFaulted: It can be used \u00a0to identify if any of the messages submitted failed. Once you have identified an error you can loop through the response item to read the error description per message failure.<\/p>\n<p><\/span><\/div>\n<p><\/p>\n<div><span><span>2.<span>\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Responses: Indicates the collection of responses.<\/p>\n<p><\/span><\/div>\n<p><\/p>\n<div><b><i><span>Note: This request will only work on organizations that have UR12 applied or on Online organizations that have been upgraded to Polaris.<\/span><\/i><\/b><span><\/p>\n<p><\/span><br \/><b><i><span><br \/><\/span><\/i><\/b><span><\/span><\/p>\n<p><span>For further read on this, you can also refer to Microsoft CRM SDK documentation on ExceuteMultiple <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/jj863631.aspx\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/span><\/p>\n<div><span><br \/><\/span><\/div>\n<p><\/p>\n<div><span><br \/><\/span><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0A new request called ExecuteMultipleRequest has been added to the Update rollup 12 for the Bulk Data Load. Using this request, multiple request can be executed with the single server call. The main advantage of this request is that it will definitely improve the performance since in one round trip to the server, it actually\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2013\/02\/use-executemultiplerequest-for-performance-improvement-in-bulk-data-load-and-other-operations\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[20,21,22,24,43],"tags":[222],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm-2011","category-dynamics-crm-2013","category-dynamics-crm-2015","category-dynamics-crm-2016","category-polaris","tag-bulk-operations"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}