Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
与 pymongo 一样,我们可以使用 $in 并将 list 传递给它。但是如果列表非常大,它可能会耗尽内存。那么如何避免呢?我可以通过 generator 而不是 list 吗?
如果列表非常大,在 pymongo 中使用 $in 查询的有效方法是什么?
MongoDB 将查询的大小限制为 16 MB(通过 BSON 文档大小限制)。因此,从技术上讲,MongoDB对于大型查询已经很高效,因为它禁止了过大的查询。
如果您要询问如何有效地查询数据库中查询集很大的文档(不一定使用 $in,也不需要预先确定的条件),有几个选项: