In-place/partial updates

Looking at mongo’s code, I see that that it still allows partial modifications of documents via RecordDamageEvent on the document instance.
Which user operations trigger mongo to use those?


bumping question, trying my luck.

Hi @Roey_Maor

Yes you are correct. I think this is internally called “updates with damages”. The ticket that implemented this feature is WT-2972, and this feature has been in place since MongoDB 3.6 series. I believe updates to a document will trigger this code (see SERVER-29250).

Having said that, this is an internal feature, the spirit of which is to increase the performance of WiredTiger for general workloads. This is not user-tunable or even user-visible, so other than a curiosity, I don’t think there’s anything you can see here :slight_smile:

Best regards


Thanks Kevin, much appreciated!

So I guess a continuing question would be - which updateOne/updateMany operations use it?
Looking at wiredtiger_record_store.cpp the answer seems to be that upon every update call we fetch the old value, and then only if:

  1. The update is large enough to satisfy the overhead (>1k)
  2. The update is smaller than the original document (+some delta)
  3. The bitwise difference between the old and new value is small enough (i.e. < 10%)

Then we use the partial modification, otherwise just insert the entire combined value as the update.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.