小编Sat*_*oko的帖子

MongoDB索引未被使用

我有一组带有修改索引的问题.

{
  "v" : 1,
  "key" : {
      "modified" : 1
  },
  "name" : "modified_1",
  "ns" : "app23568387.questions",
  "background" : true,
  "safe" : null
}
Run Code Online (Sandbox Code Playgroud)

但是当我用修改字段查询问题时,mongo不使用此索引.

db.questions.find({modified: ISODate("2016-07-20T20:58:20.662Z")}).explain(true);
Run Code Online (Sandbox Code Playgroud)

它回来了

{
  "cursor" : "BasicCursor",
  "isMultiKey" : false,
  "n" : 0,
  "nscannedObjects" : 19315626,
  "nscanned" : 19315626,
  "nscannedObjectsAllPlans" : 19315626,
  "nscannedAllPlans" : 19315626,
  "scanAndOrder" : false,
  "indexOnly" : false,
  "nYields" : 384889,
  "nChunkSkips" : 0,
  "millis" : 43334,
  "allPlans" : [ 
      {
          "cursor" : "BasicCursor",
          "isMultiKey" : false,
          "n" : 0,
          "nscannedObjects" …
Run Code Online (Sandbox Code Playgroud)

indexing mongodb

9
推荐指数
1
解决办法
467
查看次数

标签 统计

indexing ×1

mongodb ×1