MongoDB的$ in子句是否对参数数量有最大限制 [英] Does MongoDB's $in clause has any max limit in number of arguments

查看:90
本文介绍了MongoDB的$ in子句是否对参数数量有最大限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当将MongoDB的$ in子句与Aggregate一起使用时,这对参数数量是否有最大限制?

When using MongoDB's $in clause with Aggregate , Does That has any max limit in number of arguments ?

例如

Model.aggregate(
        [
            { $match : 
                { '_Id' : 
                            {
                                $in : ids
                            }
                }
            } ,
            { $group : 
                {   _id : '$roomId' ,
                    maxdate: { $max: "$date"},
                }
            },
            {$sort: { maxdate: -1} },
            {$skip: skip},
            {$limit: limitNum }
        ]

在id数组中,我可以传递多少个id?

In ids array , how many ids i can pass ?

目前,在 50,000 之前,我没有遇到 ids 长度的任何问题...但是为了安全起见,我想知道最大限制.

Currently i am not facing any issue with ids length till 50,000 ... but for safe side wanted to know the max limit.

我尝试搜索Mongo文档,但未找到任何内容.

I have tried to search on Mongo doc , but didnt find anything.

提前谢谢.

推荐答案

$ in 子句本身中的参数数量没有限制,但是,总查询大小限制为16MB作为查询只是一个BSON文档.根据用于 ids 的类型(请参阅BSON 规范),您可以当您的ID长度达到几百万时,就会开始遇到问题.

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.

这篇关于MongoDB的$ in子句是否对参数数量有最大限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆