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

Index scans don't include the final "end" check within nscanned/keysExamined

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.1.3
    • Affects Version/s: None
    • Component/s: Querying
    • Fully Compatible
    • ALL
    • Quint Iteration 3

      When scanning an index we will check a key to confirm if we have hit the end. If we have hit the end, we will stop the scan but not include that final index entry scanned within the keysExamined counter.

      Leaving the index scan
      Incrementing the keysExamined counter

      Simple reproducer:

       
      for(i=0;i<111;i++){db.t2.insert({x:i})} 
      db.t2.ensureIndex({x:1}) 
      db.t2.find({x:{$in:[3,50,74,100]}}).explain(true) 
      
       
      .... "keysExamined" : 7, 
      

      This would scan the keys at the x values of 3, 4, 50, 51, 74, 75, 100 and 101. A total of 8 keys, while the counter remains at 7

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            david.hows David Hows
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: