title: Best practice for updating a MongoDB collection with unknown modified fields
body: <p>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).</p>
  
  <p>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.</p>
  
  <p>For example, say I have a user collection (very simplified example):</p>
  
  <pre>
  user = {
    _id     :  MongoId(...),
    name    : 'User One',
    email   : 'email@address.com',
    company : 'Company',
    ...
  }
  </pre>
  
  <p>We show all editable fields in a form but the user only changes their email address. </p>
  
  <p>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?</p>
  
  <p>Or should I replace all of the editable fields anyway?</p>
  
  <p>It will be a collection containing objects and arrays within each other — not the simple one shown here.</p>
  
  <p>I know optimisation comes after, but I'm also looking to pick up good habits with MongoDB too.</p>
  
  <p>Thanks.</p>