问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/35601048/does-mongodbs-in-clause-has-any-max-limit-in-number-of-arguments