mongdb索引无法正常工作

时间:2015-07-05 13:31:49

标签: mongodb mongodb-query nosql

环境

10.10.109.131:23000   =>   shard000
10.10.109.131:23001   =>   shard001
10.10.111.251:23000   =>   shard000
10.10.111.251:23001   =>   shard001
10.10.97.197:23000    =>   shard000
10.10.97.197:23001    =>   shard001

现象

查看system.profile表扫描异常高,但再次解释查询后发现表扫描恢复正常

问题sql:

db.Followers.find({"$and":[{"$or":[{"Vaild":0},{"Vaild":null}]},{"From":{"$in":[576893,2095602,1184292,650082,1373126,875232,815151,556585,1391458,813307,600211,2273636,106322,2206656,804217]}},{"To":1600312},{"$or":[{"Vaild":null},{"Vaild":0}]}]})

system.profile

      "op" : "query",
      "ns" : "ChuyeSocial.Followers",
      "query" : {
        ...
      },
      "ntoreturn" : 0,
      "ntoskip" : 0,
      "nscanned" : 424277,
      "nscannedObjects" : 424263,

解释

shard001:PRIMARY> db.Followers.find({"$and":[{"$or":[{"Vaild":0},{"Vaild":null}]},{"From":{"$in":[576893,2095602,1184292,650082,1373126,875232,815151,556585,1391458,813307,600211,2273636,106322,2206656,804217]}},{"To":1600312},{"$or":[{"Vaild":null},{"Vaild":0}]}]}).explain()
{
    "queryPlanner" : {
        "plannerVersion" : 1,
        "namespace" : "ChuyeSocial.Followers",
        "indexFilterSet" : false,
        "parsedQuery" : {
            ...
        },
    "executionStats" : {
        "executionSuccess" : true,
        "nReturned" : 13,
        "executionTimeMillis" : 4,
        "totalKeysExamined" : 17,
        "totalDocsExamined" : 17,
        "executionStages" : {
            "stage" : "KEEP_MUTATIONS",
            "nReturned" : 13,
            "executionTimeMillisEstimate" : 0,
            "works" : 20,
            "advanced" : 13,
            "needTime" : 4,
            "needFetch" : 1,
            "saveState" : 5,
            "restoreState" : 5,
            "isEOF" : 1,
            "invalidates" : 0,

            }
        }
}

索引信息

"_id_" : 37486960,
"From_1__id_1" : 69896624,  (SharedKey)
"To_1" : 37560544
  

其他:群集中有两台机器经常突然占CPU 100%的情况

0 个答案:

没有答案