I have a MongoDB database with millions of users in collection. An aggregation function returns millions of results with the following format:

Array ( [_id] => Array ( [user] =>
  MongoId Object ( [$id] => 52050d48e654f6342c002d42 )
    [send] => 1
    [open] => 1
    [click] => 2 )

Now I need to update corresponding user with the new values (open/send/click) and for each of them add a flag, based on how the values compare with variable X.

How would be a good approach to it without looping through results (this means loading GB of data in memory and doing millions of updates/finds)




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.