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

Query with sort ($natural:1) is reported as indexOnly when it should not be

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • 2.4.0-rc0
    • None
    • Index Maintenance
    • None
    • ALL
    • Hide

      var coll = db.getCollection("covered_negative_1")
      coll.drop()
      for (i=0;i<100;i++) {
      coll.insert(

      {a:i, b:"strvar_"+(i%13), c:NumberInt(i%10), d: i*10, e: [i, i%10]}

      )
      }
      coll.insert
      coll.ensureIndex(

      {a:1,b:-1,c:1}

      )
      coll.ensureIndex(

      {e:1}

      )
      coll.ensureIndex(

      {d:1}

      )
      // Test projection and $natural sort
      var plan = coll.find({a:{$gt:70}},

      {a:1, b:1, c:1, _id:0}

      ).sort({$natural:1}).hint(

      {a:1, b:-1, c:1}

      ).explain()
      assert.eq(false, plan.indexOnly, "negative.1.5 - indexOnly should be false on a non covered query")

      Show
      var coll = db.getCollection("covered_negative_1") coll.drop() for (i=0;i<100;i++) { coll.insert( {a:i, b:"strvar_"+(i%13), c:NumberInt(i%10), d: i*10, e: [i, i%10]} ) } coll.insert coll.ensureIndex( {a:1,b:-1,c:1} ) coll.ensureIndex( {e:1} ) coll.ensureIndex( {d:1} ) // Test projection and $natural sort var plan = coll.find({a:{$gt:70}}, {a:1, b:1, c:1, _id:0} ).sort({$natural:1}).hint( {a:1, b:-1, c:1} ).explain() assert.eq(false, plan.indexOnly, "negative.1.5 - indexOnly should be false on a non covered query")

    Description

      Query with sort ($natural:1) should not be a covered query. The test below asserts with
      [false] != [true] are not equal : negative.1.5 - indexOnly should be false on a non covered query

      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: