Cost of stand-alone SKIP and LIMIT is incorrect

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • QO 2025-02-17
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      The cost of SKIP appears to be calculated identically to LIMIT, but this is not right.

      Enterprise test>  db.foo.find().skip(1).explain().queryPlanner;
      {
        winningPlan: {
          isCached: false,
          stage: 'SKIP',
          costEstimate: 0.6246551, <- cost must be equal to the cost of the input stage?
          cardinalityEstimate: 9999,
          estimatesMetadata: { ceSource: 'Metadata' },
          skipAmount: 1,
          inputStage: {
            stage: 'COLLSCAN',
            costEstimate: 4.2291755,
            cardinalityEstimate: 10000,
            numDocsEstimate: 10000,
            estimatesMetadata: { ceSource: 'Metadata' },
            direction: 'forward'
          }
        },
        rejectedPlans: []
      }
      

            Assignee:
            Milena Ivanova
            Reporter:
            Philip Stoev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: