Increase your Performance by 600% with ExecuteMultipleRequest in Dynamics CRM Update Rollup 12

Posted by on January 24, 2013  |  commentsComments (15)

I took to the latest CRM 2011 SDK to see for myself how much the new ExecuteMultipleRequest actually improves performance.  It is indeed a huge optimization especially when loading thousands of records into your CRM environment.

For my test, I am creating 500 records using only CreateRequests and another test creating 500 records with one ExecuteMultipleRequest.  I am also using CRM Online for this test and I used the CRM Online diag tool (https://orgurl/tools/diagnostics/diag.aspx) to find my latency to be 61ms.

image

Here is the first test.  A method that loops 500 times, executing the CreateRequest for each loop.

image   
 

Now for the next test.  A method that loops 500 times creating a CreateRequest for each loop but only adding them to the Requests collection of the ExecuteMultipleRequest, which gets executed at the end of the method.

image 
 

Then I used Stopwatch to display the time elapsed for each test.

image 


As you can see below, the ExecuteMultipleRequest is a huge performance increase for CRM Online as it takes 1 minute and 31 seconds when individually creating 500 records and just 14 seconds when batching them together with the ExecuteMultipleRequest. This represents a 600% increase of performance when using ExecuteMultipleRequest! Your mileage may vary from these results, but you'll definitely see a big performance improvement no matter what...so make sure you take advantage of this right away!

image

For more information and examples on using the ExecuteMultipleRequest, click here.

Comments

  1. Hi Blake,

    Thank you for the interesting info. Do you know if the set of the requests are excecuted inside a single transaction?

    Posted by: Pavel  |  Jan 25, 2013 2:57:51 AM

  2. Pavel,

    It is not a single transaction so therefore it will not rollback. The results will list out which records were successful and which ones errored so that you could do your own rollback if necessary.

    Posted by: Blake Scarlavai  |  Jan 25, 2013 9:08:30 AM

  3. Hi Blake,

    Can I execute plugins against ExecuteMultipleRequest? In my case i want to execute plugin in each record creation. Can i write plugin on create message and will it execute on ExecuteMultipleRequest?

    Posted by: Anil  |  Apr 4, 2013 4:12:27 AM

  4. Anil,

    You can write a plugin on Create and it will still execute on ExecuteMultipleRequest if it is creating records. I don't believe you can register a plugin on ExecuteMultipleRequest though.

    Posted by: Blake Scarlavai  |  Apr 4, 2013 10:17:30 AM

  5. Hi Blake,

    I have implemented the ExecuteMultipleRequest in my plugins to create/update/retrieve mutiple records. however I did not see much of the performance improvement. Further I have noticed that each ExecuteMultipleRequest is taking about 7 secs to complete which was far higher than doing the same operations in a loop. What could be wrong ?

    Posted by: Subbu  |  May 1, 2013 1:25:21 AM

  6. Subbu,

    The ExecuteMultipleRequest only has benefit when your code is not running on the CRM Server. Since your plugin is being executed on the CRM Server then this request will have little benefit. It only saves several round-trips from the client to the server but you are already on the server so no time is being saved.

    Posted by: Blake Scarlavai  |  May 1, 2013 5:27:42 AM

  7. are the requests contained in executemultiplerequest executed on the server in parallel? if so, then i would imagine that it should have a huge performance boost even if it's executed on the server, because each call is not waiting for the previous one to finish, au contrare to the for loop alternative.

    Posted by: Kenneth Leong  |  Jun 5, 2013 5:45:57 PM

  8. The requests are not executed in parallel on the server, just serially.

    Posted by: Kevin  |  Jun 11, 2013 4:23:10 PM

  9. Hi Blake,
    I want to create 10,000,000 records for pressure test.
    Now I have created a windows application with The ExecuteMultipleRequest Method.
    It's OK for running one application.
    But, when I try to run multiple applications on the same time, there is a error happened.
    Do you know the reason?
    By the way, if is it possible for running multiple applications on the same time?

    Posted by: Cecil  |  Jun 18, 2013 7:19:37 AM

  10. Cecil,

    I haven't tried running multiple at the same time but you could be running into locking issues or maybe the server is reaching its limit.

    Posted by: Blake Scarlavai  |  Jun 18, 2013 11:15:18 AM

  11. Nice...........

    Posted by: Crm Management  |  Jul 25, 2013 6:17:48 AM

  12. Is this available when using the WCF service? I don't see any generated class for the ExecuteMultipleRequest.... ?????

    Posted by: Tom McKeown  |  Jul 30, 2013 1:40:10 PM

  13. Tom,

    Is your org on UR 12 or higher?

    Posted by: Blake Scarlavai  |  Jul 30, 2013 3:26:45 PM

  14. I want to test with 1 million records. And I failed to do that because at a time it is not talking more than 1000 records! Can you provide some code to work with more than 1000 records at a time?

    I have tried a lot with the (int I=0; I< 2000; i++)!

    Please help me.

    Posted by: DC  |  Sep 18, 2014 1:46:45 PM

  15. DC,

    The default limit is 1000 records. Here's a blog post on working with more than 1000 requests at a time.

    http://torsteinutne.com/2014/01/01/executemultiplerequest-working-with-more-than-1000-requests-at-a-time/

    Posted by: Blake Scarlavai  |  Sep 18, 2014 2:19:47 PM

Post a Comment

  • *Required

Contact Us for a Quote, or Personalized Demonstrationof Microsoft Dynamics CRM for Your Business.

Contact Us