[SERVER-11825] does $addToSet cause index to be rebuilt even when document didn't change? Created: 22/Nov/13  Updated: 10/Dec/14  Resolved: 27/Nov/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Trivial - P5
Reporter: Nemanja Dubravac Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

i would like to know if performing an $addToSet on an indexed field would cause an index on this field to be rebuilt even if there is no actual change to the field?

for example, if one performed update({ $addToSet:

{ 'list': 'b' }

}) on such a document:
{
_id: 1
'list': ['a', 'b', 'c']
}



 Comments   
Comment by Eliot Horowitz (Inactive) [ 27/Nov/13 ]

In that example, no, nothing should happen.
In general, we compute an index diff by extracting the keys on the old and new doc, and then only do the deltas.

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