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

Index scans on unique indexes check to see if they should advance

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.8.0-rc1
    • Component/s: Querying
    • Labels:
      None
    • Query Execution

      Currently, when scanning any index for a number of given ranges (unique or not) we check after each found value to confirm if there is a match or we should advance the range.

      If we are using a unique index (or a field which can be confirmed to be unique by the presence of another unique index) we don't need to perform this extra check, as there can only be one matching value.

      Simple reproducer

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

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            david.hows David Hows
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: