I am Using Python 3+ and trying to update a large collection (70K documents)
All documents in the collection should be updated for ONE FIELD with the same value
I tried these Options, and it takes very long time. had to abort in between.
doc=mycollection.find({},{“mcs”:"{}"},sort=[("_id", 1)])
for data in doc:
Option1: collection.update_many({},{"$set":{“mcs”:json_data}})
Option2: requests_list = [UpdateMany({},{"$set":{“mcs”:json_data}},upsert = False)]
Option3: requests_list = [UpdateOne({},{"$set": {“mcs”: json_data}},upsert=False)] ( this will update
only one record)
collection.bulk_write(requests_list,ordered = False)