我对 mongoengine(在 python 中)有内存问题。
假设我有大量的 custom_documents(几千个)。我想处理它们,像这样:
for item in custom_documents.objects():
process(item)
问题是custom_documents.objects()
加载内存中的每个对象,我的应用程序使用了几个 GB ...
我该怎么做才能使它更明智?有没有办法让 mongoengine 懒惰地查询数据库(当我们迭代查询集时它会请求对象)?