I have a database find query which returns 4k documents, and the average size of documents is 0.3MB. The following code attempts to create a list from the cursor object. Iterating the cursor is incredibly slow!
IMongoQuery typeQuery = Query.Type("_id", BsonType.ObjectId);
MongoCursor<BsonDocument> bsonCursor = legacyCollection.Find(typeQuery);
foreach (BsonDocument bsonDoc in bsonCursor)
And I did the performance profiling with .dot Trace, please see Performance Profiling
When iterating the cursor in foreach() function, it takes too much time to get the data from MonogoDB.
I tried to improve the performance through modifying the default batch size, but it was useless.
Could you please give me some suggestions to improve the performance?