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",
        internalQueryCBRCEMode: "samplingCE",
      });
      db.a.drop()
      db.a.insertMany(Array.from({length: 100}, (_, i) => ({a: i, b: i, c: [0]})))
      db.a.createIndex({a:1, b:1, c: 1})
      db.a.explain("executionStats").find({a: 0, b: {$gte: 0}, c: 0})
      

      Gives seeks:1 but indexSeekEstimate: 100

      Show
      db.adminCommand({ setParameter: 1, internalQueryPlanRanker: "costBased" , internalQueryCBRCEMode: "samplingCE" , }); db.a.drop() db.a.insertMany(Array.from({length: 100}, (_, i) => ({a: i, b: i, c: [0]}))) db.a.createIndex({a:1, b:1, c: 1}) db.a.explain( "executionStats" ).find({a: 0, b: {$gte: 0}, c: 0}) Gives seeks:1 but indexSeekEstimate: 100
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The current logic reads:

      if (totalUniqueKeys == totalMatchingKeys) {
          ...
          return estimatedIndexKeys;
      }
      

      ie. if all the matching keys in the sample are unique, we avoid Newton-Raphson, instead returning the estimated total number of index keys.

      Instead we should return the estimated number of matching index keys.

      Noticed while working on SERVER-134637.

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

              Created:
              Updated: