I have a collection that contains DBRefs to a root document. I have tens of thousands documents that link to a single root document in my Data collection. That's why I chose to not nest the data of the root document.
Data Collection:
_id : Auto-Created ID
ts : TimeStamp
field_1 : Whatever
...
field_n : Whatever
root : DBRef
"Root" Document Collection:
_id: Filename (unique)
field_1 : Whatever
...
field_n : Whatever
I think the best way to shard my collection is using the fields ts
and root._id
as a compound key.
Is that possible? If not, what's the best solution? Simply copy the root._id
field into a normal field in the Data collection?