Hey guys,
So I'm building an app using PHP and MongoDB which will have a fair bit of traffic in both reads and writes.. After a couple of months there should be around 2500 reads a second and 200 writes per second (not sure how that really rates in terms of traffic compared to others, though).
I'm a bit curious on what to do when updating a collection; the documentation examples show a shell updating a specific collection field but doesn't explain what happens when any number of fields from the collection could have been changed.
For example, say I have a user collection (very simplified example):
user = { _id : MongoId(...), name : 'User One', email : '[email protected]', company : 'Company', ... }
We show all editable fields in a form but the user only changes their email address.
Strictly speaking in terms of performance, would it be best to store original values in hidden inputs to compare them in PHP and then building a query specific to the update?
Or should I replace all of the editable fields anyway?
It will be a collection containing objects and arrays within each other — not the simple one shown here.
I know optimisation comes after, but I'm also looking to pick up good habits with MongoDB too.
Thanks.