[DOCS-8471] Fix explanation of when indexes get updated Created: 01/Aug/16 Updated: 08/Sep/16 Resolved: 08/Sep/16 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | dochub |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Adinoyi Omuya | Assignee: | Steve Renaker (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Participants: | |||||
| Days since reply: | 7 years, 22 weeks, 6 days ago | ||||
| Story Points: | 1 | ||||
| Description |
|
The first paragraph at https://docs.mongodb.com/manual/core/write-performance/#indexes read:
Assuming the document doesn't move, only the indexes associated with fields that change (as part of the operation) get updated. Perhaps we can phrase it more along the lines of:
On MMAPv1, if the document moves, every index containing the document must be updated. |
| Comments |
| Comment by Githook User [ 08/Sep/16 ] |
|
Author: {u'username': u'steveren', u'name': u'Steve Renaker', u'email': u'steve.renaker@mongodb.com'}Message: Signed-off-by: kay <kay.kim@10gen.com> |
| Comment by Githook User [ 08/Sep/16 ] |
|
Author: {u'username': u'steveren', u'name': u'Steve Renaker', u'email': u'steve.renaker@mongodb.com'}Message: Signed-off-by: kay <kay.kim@10gen.com> |
| Comment by David Storch [ 19/Aug/16 ] |
|
steve.renaker, I don't think that is strictly correct. Setting aside sparse and partial indices, it is the case that any insert or delete of a document will have to either insert the corresponding key into every index or remove the corresponding key from any index. An update operation on any storage engine, however, may result in index keys being removed/added from some subset of the indices on the collection. Imagine that you have a collection with indices {a: 1} and {b: 1}. If you $inc field a, then we have to update the corresponding key in index {a: 1}, but there is no need to modify {b: 1}. This is true on both MMAPv1 and on WiredTiger. MMAPv1 also has a special concept of a "document move". This typically happens when an update grows a document beyond its allotted space in its data file; the MMAP storage engine deals with this by moving the document to another mmap'ed disk location (sometimes abbreviated diskloc). On MMAP, the storage engine-assigned id is the diskloc. Since every index key pointing to the document contains the record id, all index keys pointing to the document have to be updated to contain the new id. Finally, note that an MMAP document move is an expensive but usually rare operation; the storage engine leaves padding so that documents have room to grow without being moved. Hopefully this helps to clear things up! |
| Comment by Steve Renaker (Inactive) [ 18/Aug/16 ] |
|
adinoyi.omuya david.storch So is it correct to say (setting aside sparse/partial indexes for the moment) that on both WT and MMAPv1, insert and delete operations will require indexes to rebuild, whereas update operations will require a rebuild only on MMAPv1? Thanks! |
| Comment by David Storch [ 08/Aug/16 ] |
The term "move" here is specific to MMAPv1. It would be more correct to say something like this: "If the document's storage engine-assigned id changes, then all indexes on the collection must be updated accordingly. Most storage engine implementations, including WiredTiger, will not change a document's id when it is updated. An MMAPv1 document move, however, results in the id being changed." |
| Comment by Charlie Swanson [ 01/Aug/16 ] |
|
I think it might also be worth mentioning partial and sparse indexes, since those would potentially be unchanged during an insert or remove, or if a document is updated such that it still does not have an entry in the index. |