How to increase performance of the update operation in Mongo?

Viewed 3121
foreach (var doc in await records.Find(filter).ToListAsync())
{
    var query = Builders<JobInfoRecord>.Filter.Eq("JobTypeValue", doc.JobTypeValue);
    var updatedJobInfo = Regex.Replace(doc.SerializedBackgroundJobInfo, pattern, "<$1></$1>");
    var update = Builders<JobInfoRecord>.Update.Set("SerializedBackgroundJobInfo", updatedJobInfo);

    records.UpdateOneAsync(query, update).Wait();
}

Is it the best way to update document (I'm changed a values of tags in xml string that contains password in name to empty tag: ​<adminPassword></adminPassword> or demo )? I'm using Mongo driver 2.0.2

I have a collection with 500 000 documents, of which I am performing updates each minute (hopefully) of approx. 3000 documents.

How can I increase performance of the update operation?

1 Answers
Related