MongoDB index: totalDocsExamined returns 0 -


i have coded mongodb index using mongo java driver follows:

mongoclient mongoclient = new mongoclient("localhost", 27017);  db db = mongoclient.getdb("test");  dbcollection coll = db.getcollection("indexdemo");  coll.createindex(new basicdbobject("code",1));  (int ii=0;ii<100000;ii++) {  dbobject doc = new basicdbobject("code", ii);  coll.insert(doc);  } 

when execute explain plan of index (mongodb 3.x), index bounds seems recognized totalkeysexamined 0 , totaldocsexamined 0

db.indextest.find({code: 5000}).explain("executionstats") {   . . . .    "executionstats":{         "executionsuccess":true,       "nreturned":0,       "executiontimemillis":0,       "totalkeysexamined":0,       "totaldocsexamined":0,       "executionstages":{            "stage":"fetch",          "nreturned":0,          "executiontimemillisestimate":0,          "works":1,          "advanced":0,          "needtime":0,          "needfetch":0,          "savestate":0,          "restorestate":0,          "iseof":1,          "invalidates":0,          "docsexamined":0,          "alreadyhasobj":0,          "inputstage":{               "stage":"ixscan",             "nreturned":0,             "executiontimemillisestimate":0,             "works":1,             "advanced":0,             "needtime":0,             "needfetch":0,             "savestate":0,             "restorestate":0,             "iseof":1,             "invalidates":0,             "keypattern":{                  "code":1             },             "indexname":"userid_1",             "ismultikey":false,             "direction":"forward",             "indexbounds":{                  "code":[                     "[\"1111\", \"1111\"]"                ]             },             "keysexamined":0,             "dupstested":0,             "dupsdropped":0,             "seeninvalidated":0,             "matchtested":0          }       },       "allplansexecution":[          ]    }, 

when have 1 match index, defenitely totalkeysexamined=1 , totaldocsexamined=1.

  • check if use correct collection: db.getcollection("indexdemo") vs db.indextest.find()
  • make sure db.indextest.find({code: 5000}) returns 1 document. have nreturned=0.
  • check index name: if create index {code: 1} named code_1 , stats shows "indexname":"userid_1"

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -