Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-12628

Explain should indicate whether index filters were applied

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.0-rc0
    • Affects Version/s: 2.5.5
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible

      It is confusing that explain() does not indicate whether an index filter was applied. Including this information can significantly help the slow-query debugging process.

      > db.foo.insert({_id:0, a:1})
      SingleWriteResult({
      	"writeErrors" : [ ],
      	"writeConcernErrors" : [ ],
      	"nInserted" : 1,
      	"nUpserted" : 0,
      	"nUpdated" : 0,
      	"nModified" : 0,
      	"nRemoved" : 0,
      	"upserted" : [ ]
      })
      > db.foo.runCommand("planCacheSetFilter",{query:{a:1},indexes:[{_id:1}]})
      { "ok" : 1 }
      > db.foo.find({a:1}).hint({a:1}).explain()
      {
      	"cursor" : "BasicCursor", // no indication as to why hinted index is not being used
      	"n" : 1,
      	"nscannedObjects" : 1,
      	"nscanned" : 1,
      	"nscannedObjectsAllPlans" : 1,
      	"nscannedAllPlans" : 1,
      	"scanAndOrder" : false,
      	"indexOnly" : false,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 0,
      	"server" : "Rassi-MacBook-Pro.local:27017"
      }
      >
      

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: