Global index counters not updated in all code paths

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.2.4, 2.4.1
    • None
    • Fully Compatible
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Some index accesses update the global index counters; some don't.

      MongoDB shell version: 2.2.4
      connecting to: test
      > db.version()
      2.2.4
      > db.hostInfo().os
      { "type" : "Linux", "name" : "Ubuntu", "version" : "12.04" }
      > show dbs
      local	(empty)
      > db.test.insert({a:1})
      > db.test.ensureIndex({a:1})
      > db.serverStatus().indexCounters.btree
      {
      	"accesses" : 1,
      	"hits" : 1,
      	"misses" : 0,
      	"resets" : 0,
      	"missRatio" : 0
      }
      > db.test.find()
      { "_id" : ObjectId("51632bd680036fc7eb0cbdea"), "a" : 1 }
      > db.test.find({_id: ObjectId("51632bd680036fc7eb0cbdea")})
      { "_id" : ObjectId("51632bd680036fc7eb0cbdea"), "a" : 1 }
      > db.serverStatus().indexCounters.btree
      {
      	"accesses" : 2,
      	"hits" : 2,
      	"misses" : 0,
      	"resets" : 0,
      	"missRatio" : 0
      }
      > db.test.find({a:1})
      { "_id" : ObjectId("51632bd680036fc7eb0cbdea"), "a" : 1 }
      > db.test.find({a:1}).explain()
      {
      	"cursor" : "BtreeCursor a_1",
      	"isMultiKey" : false,
      	"n" : 1,
      	"nscannedObjects" : 1,
      	"nscanned" : 1,
      	"nscannedObjectsAllPlans" : 1,
      	"nscannedAllPlans" : 1,
      	"scanAndOrder" : false,
      	"indexOnly" : false,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 0,
      	"indexBounds" : {
      		"a" : [
      			[
      				1,
      				1
      			]
      		]
      	},
      	"server" : "tad-ubuntu:27017"
      }
      > db.serverStatus().indexCounters.btree
      {
      	"accesses" : 2,
      	"hits" : 2,
      	"misses" : 0,
      	"resets" : 0,
      	"missRatio" : 0
      }
      
      MongoDB shell version: 2.4.1
      connecting to: test
      > db.version()
      2.4.1
      > db.hostInfo().os
      { "type" : "Linux", "name" : "Ubuntu", "version" : "12.04" }
      > show dbs
      local	0.078125GB
      > db.test.insert({a:1})
      > db.test.ensureIndex({a:1})
      > db.serverStatus().indexCounters
      {
      	"accesses" : 1,
      	"hits" : 1,
      	"misses" : 0,
      	"resets" : 0,
      	"missRatio" : 0
      }
      > db.test.find()
      { "_id" : ObjectId("51632d682b2597dfbeae7f92"), "a" : 1 }
      > db.test.find({_id: ObjectId("51632d682b2597dfbeae7f92")})
      { "_id" : ObjectId("51632d682b2597dfbeae7f92"), "a" : 1 }
      > db.serverStatus().indexCounters
      {
      	"accesses" : 2,
      	"hits" : 2,
      	"misses" : 0,
      	"resets" : 0,
      	"missRatio" : 0
      }
      > db.test.find({a:1})
      { "_id" : ObjectId("51632d682b2597dfbeae7f92"), "a" : 1 }
      > db.test.find({a:1}).explain()
      {
      	"cursor" : "BtreeCursor a_1",
      	"isMultiKey" : false,
      	"n" : 1,
      	"nscannedObjects" : 1,
      	"nscanned" : 1,
      	"nscannedObjectsAllPlans" : 1,
      	"nscannedAllPlans" : 1,
      	"scanAndOrder" : false,
      	"indexOnly" : false,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 0,
      	"indexBounds" : {
      		"a" : [
      			[
      				1,
      				1
      			]
      		]
      	},
      	"server" : "tad-ubuntu:27017"
      }
      > db.serverStatus().indexCounters
      {
      	"accesses" : 2,
      	"hits" : 2,
      	"misses" : 0,
      	"resets" : 0,
      	"missRatio" : 0
      }
      

      Indexed access using _id adds to the index counters. Indexed access using the "a" key in this example does not add to the index counters.

            Assignee:
            Unassigned
            Reporter:
            Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: