Get changed data after execute bulk

15 views
Skip to first unread message

Masco

unread,
Jul 19, 2017, 4:41:51 PM7/19/17
to mongodb-user
Hello

I have recently started using the bulk operation to perform massive upgrades. I wanted to know what documents have been modified according to the query provided, to later obtain some data from the documents. When you run "bulk.getOperations();" I do not return only the changed documents, but all the queries executed and all the documents.

Is there any way to get the documents changed? The problem with running individual updates is that they are several million records running and the server is triggered in memory and CPU consumption, currently executing bulk in groups of 1000 querys, which I divide before. I only get the idea of getting the date before executing the bulk, use a date field with the current date in the update and once finished, look for the documents larger than that date.

Any ideas? Thank you.

Best regards

Rhys Campbell

unread,
Jul 20, 2017, 4:11:52 AM7/20/17
to mongodb-user
I think you have two options;

1. Get changed documents from the oplog - https://docs.mongodb.com/manual/core/replica-set-oplog/. This could get fiddly if you have sharding.
2. Add a last changed datetime field to documents you update.

Masco

unread,
Jul 20, 2017, 6:36:08 PM7/20/17
to mongodb-user
Thanks !
Reply all
Reply to author
Forward
0 new messages