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

CE: Estimate is zero in cases where the index key is a tranformation of the original value

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • ALL
    • Hide
      
      db.foo.drop();
      db.foo.insertMany([{a: 1}]);
      db.foo.createIndex({a: 'hashed'});
      db.foo.runCommand({analyze: "foo", key: "a"});
      db.adminCommand({setParameter: 1, planRankerMode: "histogramCE"});
      db.foo.find({a: 1}).explain().queryPlanner.winningPlan;
      
      Show
      db.foo.drop(); db.foo.insertMany([{a: 1}]); db.foo.createIndex({a: 'hashed' }); db.foo.runCommand({analyze: "foo" , key: "a" }); db.adminCommand({setParameter: 1, planRankerMode: "histogramCE" }); db.foo.find({a: 1}).explain().queryPlanner.winningPlan;

      In the cases where the index bounds are a transformation of the original bounds, the estimate is zero as the transformed bounds can never be found in the histogram. Cases include:

      • hashed indexes
            indexBounds: { a: [ '[5902408780260971510, 5902408780260971510]' ] }
        
      • collations:
              indexBounds: { a: [ '[CollationKey(0x3d0105), CollationKey(0x3d0105)]' ] }
      

      Timour enumerated the following 3 potential solutions:

      • Do not use histogram CE when the index bounds are transformed (e.g. hashed) constants
      • Store the original bounds in the interval
      • Establish equivalence of interval and predicate, and use the constant from the predicate when the bounds are transformed

            Assignee:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Reporter:
            philip.stoev@mongodb.com Philip Stoev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: