MongoDB。db.collection.explain().find()与db.collection.find().explain()的比较

MongoDB。db.collection.explain().find()与db.collection.find().explain()的比较,mongodb,mongodb-indexes,Mongodb,Mongodb Indexes,这两个命令之间有什么区别 db.collection.explain().find() db.collection.find().explain() 运行返回一个对象,该对象可用于生成聚合、计数、查找、分组、删除和更新操作的解释计划。从MongoDB 3.0开始,这是生成解释计划的首选方法 (允许db.collection.find().explain()运行)主要是为了向后兼容3.0之前的MongoDB版本。这将生成与db.collection.explain()相同的解释输出,但仅限于f

这两个命令之间有什么区别

db.collection.explain().find() 
db.collection.find().explain()
运行返回一个对象,该对象可用于生成聚合、计数、查找、分组、删除和更新操作的解释计划。从MongoDB 3.0开始,这是生成解释计划的首选方法

(允许db.collection.find().explain()运行)主要是为了向后兼容3.0之前的MongoDB版本。这将生成与db.collection.explain()相同的解释输出,但仅限于find操作

如果所有其他操作都相同,我建议使用db.collection.explain(),它支持更多的操作集