The update code has two paths for writing an update to a document:
- "Update with damages". This path computes a "damage vector", which consists of a set of damages to apply to a document. Each damage is a byte array, along with an offset at which to copy this byte array into the document. This is essentially a delta-based description of the update. This is an optimized code path which can apply the update to storage more efficiently.
- The regular update path, in which the UpdateDriver computes the full post-image and then writes the resulting complete post-image to the Collection.
The update with damages path cannot currently be used for updates that affect indexes. (See the code here where we turn off in-place updates when indexes are affected.) We should lift this restriction in order to allow more updates to use the optimized code path.
In the current update framework updates to indexed fields cannot be 'fastmods', meaning that they require re-serializing the document.
This makes simple updates to indexed fields more expensive than they need to be.
We should improve the interaction between the update framework and the index update subsystem to permit fastmod updates to indexed fields.