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

Explain should indicate whether index filters were applied

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.6.0-rc0
    • 2.5.5
    • Querying
    • None
    • Fully Compatible

    Description

      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"
      }
      >

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: