-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: 1.5.2
-
Component/s: Performance
-
None
I'm looking at optimizations that can be made for mongorestore.
Since we insert raw BSON, I don't think we need to run bson.MarshalAppendWithRegistry() in transformAndEnsureID(). It would be nice to skip this if val holds a value of type bson.Raw or []byte and just set doc = val.
This does mean that if the original value doesn't have an _id field, we could end up mutating val. This can't happen for mongorestore, but would be unwanted potential behavior. Perhaps we can copy val only if we are about to mutate its array.
This would avoid copying data unnecessarily if we don't need to do so.