What happens after an update to this column is made? What does MongoDB do? What is the time-complexity to keep this column sorted after each update?
CodePudding user response:
MongoDB doesn't keep the documents sorted.
The index entries are stored in a btree-like structure. When a value is updated, the entry containing the old entry is removed, and a new entry is inserted at the appropriate point in the tree.
Wikipedia reports the time complexity of both insert and delete in a btree as O(log n).