ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • ALL
    • Hide

       

      db.adminCommand({ setParameter: 1, internalQueryPlanRanker: 'costBased' })
      db.a.drop()
      db.a.createIndex({a:1, b: 1, c: 1})
      db.a.insertMany(Array.from({length: 100}, (_, i) => {return {a: 1, b: i, c: 0};}))
      printjson(db.a.explain("executionStats").find({a: 0, b: {$gt: 0}, c: 0}).finish().executionStats.executionStages.inputStage)
      

      Notice that:
      seeks: 1,
      But
      indexSeekEstimate: 100,

      Show
        db.adminCommand({ setParameter: 1, internalQueryPlanRanker: 'costBased' }) db.a.drop() db.a.createIndex({a:1, b: 1, c: 1}) db.a.insertMany(Array.from({length: 100}, (_, i) => { return {a: 1, b: i, c: 0};})) printjson(db.a.explain( "executionStats" ).find({a: 0, b: {$gt: 0}, c: 0}).finish().executionStats.executionStages.inputStage) Notice that: seeks: 1, But indexSeekEstimate: 100,
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      cardinality_estimator.cpp currently drops point predicates even if they prefix the field(s) the scan would seek on. This results in the number of seeks being over-estimated.

      In the example above, the `a: 0` constraint is dropped alongside `c: 0`, leaving only `b:{$gt: 0}` to be NDV-estimated. All documents in the collection have different `b` values, so this comes back as the collection cardinality, whereas during execution the index scan seeks only once since no documents match `a:0`.

            Assignee:
            Unassigned
            Reporter:
            Kartal Kaan Bozdogan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: