[SERVER-12732] Permit delta-based updates (update by a damage vector) to indexed fields Created: 14/Feb/14  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 2
Labels: Performance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Participants:

 Description   

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.

Original description

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.



 Comments   
Comment by David Storch [ 24/Apr/18 ]

This limitation still exists. The code which computes the set of index keys to delete and index keys to insert relies on the full pre-image and post-image of the document:

https://github.com/mongodb/mongo/blob/67b5cff517548bc943c819308da452a2b35f5c28/src/mongo/db/index/index_access_method.cpp#L343-L370

Removing this restriction would require us to improve the key generation code to be able to compute index key changes from the damage vector.

Comment by James Blackburn [ 25/Feb/14 ]

See also: SERVER-12886

This can be fixed by something like:
https://github.com/jamesblackburn/mongo/compare/SERVER-12886

which implements SERVER-66. Essentially it attempts to write back just dirty pages, which makes a big difference to small updates to larger documents.

Generated at Thu Feb 08 03:29:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.