What is the maximum number of parameters passed to $in query in MongoDB?

前端 未结 4 1073
梦毁少年i
梦毁少年i 2020-12-05 17:05

What is the maximum number of parameters passed to $in query in MongoDB?

4条回答
  •  一个人的身影
    2020-12-05 17:19

    Looks like there is no limitation.

    I did a small test.

    1) Collection A had - 1 Million simple JSON object {id:,name:}

    2) In Collection B, I loaded reference ids of collection A till I got the following exception. I could insert a reference count of 450k of max.

    Exception in thread "main" com.mongodb.MongoInternalException: DBObject of size 18388885 is over Max BSON size 16777216
    

    3) I could send 450k of these ids as $in[id1...id450000] and pull the whole list of 450k ids from 1 Million objects in collection A.

    Wow! this is more more more than enough for my application :D. MongoDB is really cool.

提交回复
热议问题