2 / 5
Mar 14

After updating MongoDB.Driver library from 2.30.0 to 3.2.0 we experience huge performance downfall, its 20-50x slower.

From what I have gathered, same issue appears on 2.30.0 if LinqProvider is set to V3 instead of LinqProvider.V2.

We are using IAggregateFluent queries for these requests.

Is this known issue and are there any suggestions that might help us move to latest version of MongoDB.Driver?

Hey @Peteris_Lideris,

Welcome to the MongoDB Community Forums. Do you have an example of a specific query where you’re seeing this degradation? Is it any LINQ Query between V2 and V3 where you’re seeing this? Also is it the response time in the query where you’re seeing this? We can help investigate with more details.

Thanks,

Rishit.

Hi,

I was able to set up an example to demonstrate the issue. It seems to be related to the connection type (local or cloud). However, even with a local connection, performance appears to be about 20% slower. When not local, the performance difference is significant, ranging from 20x to 50x slower.

Here’s the repository I used for testing:
GitHub - mongodb-linq-issue

For faster local setup, I used .NET Aspire. You can switch between LINQ versions by commenting/uncommenting these lines in Program.cs:

// settings.LinqProvider = LinqProvider.V3; settings.LinqProvider = LinqProvider.V2;

Additionally, you can adjust the seed array (bucketIds) in ExampleCollectionSeed.cs to reduce the number of generated documents.

Results

Here are my local test results with the current setup:

LINQ V2:

  • Time spent: 00:01:11.4165811 (2800 results)
  • Time spent: 00:01:07.4483099 (2800 results)
  • Time spent: 00:01:07.4265999 (2800 results)
  • Time spent: 00:01:07.2861247 (2800 results)
  • Time spent: 00:01:07.1483622 (2800 results)

LINQ V3:

  • Time spent: 00:01:25.3082952 (2800 results)
  • Time spent: 00:01:23.6927336 (2800 results)
  • Time spent: 00:01:22.7419893 (2800 results)
  • Time spent: 00:01:24.4259722 (2800 results)
  • Time spent: 00:01:23.5046322 (2800 results)

Let me know if additional information or adjustments are needed!

Hi Rishit,

Thank you for creating the ticket and looking into this. I’ll keep an eye on the updates.

Best regards,
Peteris