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

Do result projections on covered indexes only use the index?

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Index Maintenance
    • None

    Description

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: