Hi Andrzej
It’s been some time since you posted this question. Have you managed to finish the update?
It sounds to me like the hardware you have is struggling to update all 40M documents in one go. To minimize the impact to your other operation, I would suggest you to do the process in controlled batches, e.g.:
db.getCollection('test').find({_id: <some restricted range of _id>}).forEach( function(data) {
db.getCollection('test').update({_id: data._id}, {$set: {firstname: hex_md5(data.firstname)}})
});
Having said that, if your update is touching every single document in the collection, the operation is likely to be bound by disk speed (unless the whole collection can fit in memory).
On another note, it’s generally not recommended to use noCursorTimeout(). The reason being, the server will keep the cursor open indefinitely. If the application crashes or stops working for any reason, that cursor will never be closed by the server, resulting in a resource leak that can only be fixed with a restart.
Best regards
Kevin