When using MongoDB's $in clause with Aggregate , Does That has any max limit in number of arguments ?
for example
Model.aggregate(
[
{ $match :
{ '_Id' :
{
$in : ids
}
}
} ,
{ $group :
{ _id : '$roomId' ,
maxdate: { $max: "$date"},
}
},
{$sort: { maxdate: -1} },
{$skip: skip},
{$limit: limitNum }
]
In ids array , how many ids i can pass ?
Currently i am not facing any issue with ids length till 50,000 ... but for safe side wanted to know the max limit.
I have tried to search on Mongo doc , but didnt find anything.
Thanks in advance.
MongoDB limits document sizes (as of version 2.4. 0+) to 16 MB. So, no matter what the size of an individual number, it's the same bsonsize.
The maximum size an individual document can be in MongoDB is 16MB with a nested depth of 100 levels. Edit: There is no max size for an individual MongoDB database.
The maximum BSON document size is 16 megabytes. The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API.
The $in operator selects the documents where the value of a field equals any value in the specified array. To specify an $in expression, use the following prototype: { field: { $in: [<value1>, <value2>, ... < valueN> ] } } For comparison of different BSON type values, see the specified BSON comparison order.
There is no limit to the number of arguments in the $in
clause itself, however, the total query size is limited to 16MB as a query is just a BSON document. Depending on the type used for ids
(see the BSON specification), you may start running into problems when your ids length is in the order of a few millions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With