【问题标题】:MongoDB. db.collection.explain().find() vs db.collection.find().explain()MongoDB。 db.collection.explain().find() 与 db.collection.find().explain()
【发布时间】:2015-08-27 12:39:37
【问题描述】:

这两个命令有什么区别?

db.collection.explain().find() 
db.collection.find().explain()

【问题讨论】:

    标签: mongodb mongodb-indexes


    【解决方案1】:

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

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

    如果其他一切都一样,我建议使用支持更多操作集的 db.collection.explain()。

    【讨论】:

      猜你喜欢
      • 2015-02-28
      • 2015-06-26
      • 1970-01-01
      • 2015-04-06
      • 2013-12-17
      • 2015-05-20
      • 2017-03-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多