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

Not in covered index query does not have nscannedObjects = 0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • None
    • None
    • > 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")

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: