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

Not in covered index query does not have nscannedObjects = 0

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      > db.version()
      2.4.0-rc0
      on OS X
    • ALL
    • Hide

      testDB = db.getSiblingDB("qa293")
      var coll = testDB.getCollection("simple.1")
      coll.drop()
      for (i=0;i<10;i++) {
      coll.insert(

      {foo:i}

      )
      }
      for (i=0;i<10;i++) {
      coll.insert(

      {foo:i}

      )
      }
      for (i=0;i<5;i++) {
      coll.insert(

      {bar:i}

      )
      }
      coll.insert(

      {foo:"1"}

      )
      coll.insert({foo:{bar:1}})
      coll.insert(

      {foo:null}

      )
      coll.ensureIndex(

      {foo:1}

      )

      // Test not in query
      var plan = coll.find({foo:{$nin:[5,8]}},

      {foo:1, _id:0}

      ).hint(

      {foo:1}

      ).explain()
      assert.eq(true, plan.indexOnly, "simple.1.8 - indexOnly should be true on covered query")
      assert.eq(0, plan.nscannedObjects, "simple.1.8 - nscannedObjects should be 0 for covered query")

      Show
      testDB = db.getSiblingDB("qa293") var coll = testDB.getCollection("simple.1") coll.drop() for (i=0;i<10;i++) { coll.insert( {foo:i} ) } for (i=0;i<10;i++) { coll.insert( {foo:i} ) } for (i=0;i<5;i++) { coll.insert( {bar:i} ) } coll.insert( {foo:"1"} ) coll.insert({foo:{bar:1}}) coll.insert( {foo:null} ) coll.ensureIndex( {foo:1} ) // Test not in query var plan = coll.find({foo:{$nin: [5,8] }}, {foo:1, _id:0} ).hint( {foo:1} ).explain() assert.eq(true, plan.indexOnly, "simple.1.8 - indexOnly should be true on covered query") assert.eq(0, plan.nscannedObjects, "simple.1.8 - nscannedObjects should be 0 for covered query")

      Expecting a covered index query to have nscannedObjects to be 0 with a nin query on the indexed field. This is the case when the index is a regular, unique or sparse unique.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sridhar Sridhar Nanjundeswaran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: