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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • 2.8.0-rc1
    • Querying
    • None
    • Query Execution

    Description

      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, 

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            david.hows David Hows
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated: