首页 > 解决方案 > 是否可以在多进程中使用 find_raw_batches?

问题描述

我习惯于使用多进程来提高慢速 mongo 查询的性能,但在这些情况下,我使用 $in 将列表输入到查询中,并且要使用多进程,我只需给每个进程一个大小均匀的块列表。

是否可以通过在 find_raw_batches 之上使用多进程来获得有用的性能提升?我担心结果会重叠。

import bson
cursor = db.test.find_raw_batches()
for batch in cursor:
    print(bson.decode_all(batch))

标签: pythonpymongomultiprocess

解决方案


推荐阅读