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

histogramCE: Estimate for $ne is zero in the presence of -Infinity , index

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • ALL
    • Hide
      db.foo.drop();
      
      let integer_docs = [];
      
      for (let i = 1; i < 100; i++) {
          integer_docs.push({a: i});
      }
      
      integer_docs.push({a: Number.NEGATIVE_INFINITY});
      
      db.foo.insertMany(integer_docs);
      db.foo.createIndex({a: 1});
      db.foo.runCommand({analyze: "foo", key: "a"});
      db.adminCommand({setParameter: 1, planRankerMode: "histogramCE"});
      db.foo.find({a: {$ne: -1}}).explain();
      
      Show
      db.foo.drop(); let integer_docs = []; for (let i = 1; i < 100; i++) { integer_docs.push({a: i}); } integer_docs.push({a: Number .NEGATIVE_INFINITY}); db.foo.insertMany(integer_docs); db.foo.createIndex({a: 1}); db.foo.runCommand({analyze: "foo" , key: "a" }); db.adminCommand({setParameter: 1, planRankerMode: "histogramCE" }); db.foo.find({a: {$ne: -1}}).explain();

      The cardinality estimate for $ne over some values in the presence of -Infinity in the index is zero.

      Enterprise test> db.foo.find({a: {$ne: -1}}).count();
      100
      
      Enterprise test> db.foo.find({a: {$ne: -1}}).explain().queryPlanner.winningPlan.cardinalityEstimate;
      0
      

            Assignee:
            timour.katchaounov@mongodb.com Timour Katchaounov
            Reporter:
            philip.stoev@mongodb.com Philip Stoev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: