web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Dynamics CRM 8.2 On-Prem - OData (.NET 7 Simple.OData.Client) performing slower than OrganizationService (.NET Framework 4.8)

(0) ShareShare
ReportReport
Posted on by 5

Hello everyone. 

I'm currently tasked with optimizing some old badly functioning SSIS packages, and rewriting them entirely in Console Applications for more control over the logic.

I've run into an odd issue, which is that the .NET Framework 4.8 outperforms the .NET 7 OData implementation, with almost four times faster batch inserts.


While it's not a big issue in itself, it doesn't feel right to be stuck in .NET Framework 4.8 when there is so many improvements in .NET 7.

My question is, have I missed anything in the implementation of the OData client? Or is OrganizationService just better performance than any custom implementation OData?


Code examples. I have 5000 Entities in a list, running on 10 threads, and the batch sizes is 200, with 

ThreadPool.SetMinThreads(100, 100);
System.Net.ServicePointManager.DefaultConnectionLimit = 65000;
System.Net.ServicePointManager.Expect100Continue = false;
System.Net.ServicePointManager.UseNagleAlgorithm = false;

OrganizationService implementation:

Parallel.ForEach(entityList.ChunkBy(200), parallelOptions,chunk =>
{
var localOrganizationService = ConnectionService.GetOrganizationService();

var executeMultiple = new ExecuteMultipleRequest
{
Settings = new ExecuteMultipleSettings
{
ContinueOnError = true,
ReturnResponses = true
},
Requests = new OrganizationRequestCollection()
};

foreach (var coveragePolicy in chunk)
{
executeMultiple.Requests.Add(new DeleteRequest{Target = entity.ToEntityReference()});

if(executeMultiple.Requests.Count > 100)
{
localOrganizationService.Execute(executeMultiple);
executeMultiple.Requests.Clear();
}
}

if(executeMultiple.Requests.Count > 0)
{
localOrganizationService.Execute(executeMultiple);
}
});

and the OData implementation:

await Parallel.ForEachAsync(list.Chunk(200), parallelOptions, async (chunk, _) =>
{
var batch = new ODataBatch(ConnectionService.GetODataClient());

foreach (var entity in chunk)
{
batch += async oDataClient => await oDataClient.For<Entity>().Set(entity).InsertEntryAsync(false, _);
}

await batch.ExecuteAsync(_);
});

Performance difference with 5000 Entities inserted, Threadsize 10, Batch size 200:

OrganizationService: 37.2 seconds, 134 inserts per second -- 167 deletes per second

OData: 262.6 seconds, 19 inserts per second -- 130 Deletes per second

The implementation is pretty much identical in terms of setup and execution, but performance is simply slower in OData.

The funny thing is that OData performs quite well (but still not as good) as the OrganizationService in regards to Deletion, but the inserts are much more slower. 

Is there any radical changes to the OData that I havent implemented yet, or is OrganizationService just better+

Naturally, I'd much rather go for the new and shiny .NET 7, however performance is key, so unless I find out a glaring mistake, I'll have to stay with .NET Framework 4.8.

I have the same question (0)
  • Verified answer
    Ray Profile Picture
    1,537 on at

    Per this doc there should be no different between OrganizationService and Odata batch.

    I would suggest capturing the HTTP request and response and capturing the SQL profiler to see if there is any different.

  • RMBP Profile Picture
    5 on at

    Good idea with capturing the requests and responses, didn't think of that. That'd probably explain what I need. Thanks. :-)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 137 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 57

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans