I'm trying to store a list of ObjectIds in a document as an array field.
I understand Mongo DB has a 4MB size limit for single documents. So considering the length of ObjectId is 12 bytes, a document should be able to handle more than 300,000 entries in one array field. (Let me know if the calculation is off).
If the number of entries in the array gets close to that limit, what kind of performance can I expect? Especially when the field is indexed? Any memory issues?
Typical queries would look like below:
Query by a single value
db.myCollection.find(
{
myObjectIds: ObjectId('47cc67093475061e3d95369d')
}
);
Query by multiple values
db.myCollection.find(
{
myObjectIds: {$in: [ObjectId('47cc67093475061e3d95369d'), ...]}
}
);
Add a new value to multiple documents
db.myCollection.update(
{
_id: {$in: [ObjectId('56cc67093475061e3d95369d'), ...]}
},
{
$addToSet: {myObjectIds: ObjectId('69cc67093475061e3d95369d')}
}
);