[GODRIVER-2022] Don't Marshal bson.Raw values in transformAndEnsureID() Created: 23/May/21  Updated: 06/Sep/22

Status: Backlog
Project: Go Driver
Component/s: Performance
Affects Version/s: 1.5.2
Fix Version/s: None

Type: Improvement Priority: Unknown
Reporter: Tim Fogarty Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Quarter: FY23Q2, FY23Q3

 Description   

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.


Generated at Thu Feb 08 08:37:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.