0

I am wondering about nscannedObjectsAllPlans/nscannedAllPlans in the output of mongodb explain(). As far as I understand, Mongo runs several plans (if available) and picks the fastest. The information about the plans are kept for another 100 writes. So, does this output mean that there were 12412 documents in the collection? That is not right. Because I just added a document and removed it from the collection and then the 12412 the nscannedObjectsAllPlans increased to 12412.

"cursor" : "BtreeCursor x_1",
    "n" : 2301,
    "nscannedObjects" : 12330,
    "nscanned" : 12330,
    "nscannedObjectsAllPlans" : 12412,
    "nscannedAllPlans" : 12412,
    "millis" : 98

After removing an object from the collection, the nscannedObjectsAllPlans is a ridiculous number "12412" which I don't understand the reason of. Can anybody explain this output of explain()

user3111525
  • 5,013
  • 9
  • 39
  • 64
  • nscanned is a counter it can include duplicate documents, in this case AllPlans is all methods of finding via all indexes – Sammaye Nov 21 '13 at 13:44
  • 1
    Actually query plans are updated after 1000 not 100 writes. Also when you run `explain` it reevaluates query plans every time you run it. – zero323 Nov 21 '13 at 14:27
  • To understand the number of index entries and documents scanned, you would need to provide the full output of your query with [`explain(true)`](http://docs.mongodb.org/manual/reference/method/cursor.explain/), eg `db.collection.find({...}).explain(true)`. The optional parameter for explain() asks for "verbose" details (information for all plans considered). – Stennie Dec 01 '13 at 11:08

0 Answers0