我正在使用聚合查询来联接两个表,并将输出插入到新集合中。
这两个馆藏的记录数超过一百万。 该查询在命令提示符下的2分钟内返回值,但在下一个阶段无限期运行。
result = list(db.insight_assets.aggregate(pipeline))
temp = []
count = 0
batch = 0
for doc in result:
count += 1
temp.append(doc)
if count == 5000:
db.insight_temp_uber.insert_many(temp)
batch += 1
print("Batch:", batch)
count = 0
temp.clear()
查询需要很长时间才能将光标转换为列表(用于百万条记录)
列表(db.insight_assets.aggregate(管道))
管道查询由5到6个阶段组成,这些阶段已进行了优化,但汇总查询的输出必须插入到新集合中。
还有什么其他方法可以让我快速阅读并将数据插入新集合中。