如何使用db.command获取Python Mongo Aggregate解释?

时间:2019-05-22 11:35:58

标签: python mongodb pymongo

  

从MongoDB 3.2开始,explain()使用默认的详细模式:   说明命令allPlansExecution。使用不同的详细程度   使用command()直接运行explain命令。

我的汇总查询看起来像这样

collection.aggregate(pipeline=QUERY, explain=True)

这将返回queryPlanner而不是executionStats

mongo shell支持什么?

db.Item_Process_For_Report.explain("executionStats").aggregate([])

我想做什么?

db.command('explain', <What goes here>)

1 个答案:

答案 0 :(得分:0)

截至2019年5月22日,使用MongoDB 4.0

pymongo当前仅允许通过db.command()进行解释,并且在内部使用Aggregation Command和Aggregation将解释限制为布尔开关,默认为QueryPlanner,如here