Do result projections on covered indexes only use the index?

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      for a collection "foo" with index

      {x:1}

      , will a query like db.foo.find({},{_id:0,x1}).hint(

      {x:1}

      ) touch the data? or will it be completely answered via the data stored in the index?

      The explain verifies that it's "indexOnly", but I'm not sure what that means wrt to the actual results:

      > db.foo.find({},{_id:0,x:1}).hint({x:1}).explain()
      {
      	"cursor" : "BtreeCursor x_1",
      	"isMultiKey" : false,
      	"n" : 100,
      	"nscannedObjects" : 100,
      	"nscanned" : 100,
      	"nscannedObjectsAllPlans" : 100,
      	"nscannedAllPlans" : 100,
      	"scanAndOrder" : false,
      	"indexOnly" : true,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 0,
      	"indexBounds" : {
      		"x" : [
      			[
      				{
      					"$minElement" : 1
      				},
      				{
      					"$maxElement" : 1
      				}
      			]
      		]
      	},
      	"server" : "hoffrocket.local:27017"
      }
      

            Assignee:
            Unassigned
            Reporter:
            Jon Hoffman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: