how to get Python Mongo Aggregate explain using db.command?

房东的猫 提交于 2019-12-11 14:18:49

问题


Starting with MongoDB 3.2 explain() uses the default verbosity mode of the explain command, allPlansExecution. To use a different verbosity use command() to run the explain command directly.

My aggregate query looks something like this

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

This returns queryPlanner verbose and not executionStats.

What mongo shell supports?

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

What am I trying to do?

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

回答1:


As on 22-May-2019 with MongoDB 4.0

pymongo currently allows explain only via db.command() and this internally uses the Aggregation Command and Aggregation which limits explain to a Boolean switch which defaults to QueryPlanner as seen here



来源:https://stackoverflow.com/questions/56255968/how-to-get-python-mongo-aggregate-explain-using-db-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!