MongoDB moves cursor too slowly

I have a search query for a database that returns 4k documents and the average size of documents is 0.3 MB. The following code attempts to create a list from a cursor object. Cursor iteration is incredibly slow!

IMongoQuery typeQuery = Query.Type("_id", BsonType.ObjectId);
MongoCursor<BsonDocument> bsonCursor = legacyCollection.Find(typeQuery);
foreach (BsonDocument bsonDoc in bsonCursor)

And I performed performance profiling with .dot Trace, see Performance Profiling

When you repeat the cursor in the foreach () function, it takes too much time to get data from MonogoDB.

I tried to improve performance by changing the default batch size, but that was useless.

Could you give me some tips for improving performance?

+4
source share

Source: https://habr.com/ru/post/1664874/


All Articles