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

Plan enumerator can generate duplicate plans

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • QO 2024-04-29, QO 2024-05-13, QO 2024-05-27, QO 2024-06-10, QO 2024-06-24, QO 2024-07-08
    • 200

      In the explain output generated by this script, I see duplicate plans being considered.

      coll = db.c;
      coll.drop()
      
      coll.insert({t: 1, m: 1, a: 1, b: 1, c: 1, d: 1})
      
      assert.commandWorked(coll.createIndex({m: 1, t: 1}))
      assert.commandWorked(coll.createIndex({t: 1, m: 1, a: 1}))
      
      jsTestLog(coll.explain().aggregate([
          {$match: {$and: [{t: {$eq: {c: 1, d: 1}}}, {m: {$eq: {c: 1, d: 1}}}]}},
          {$match: {$or: [{t: {$gte: {c: 1, d: 1}}}, {t: {$lte: {c: 1, d: 1}}}]}}
      ]))
      

      Multiplanning duplicate plans is wasteful. This may be an issue if it's possible to reproduce on more realistic queries

            Assignee:
            henri.nikku@mongodb.com Henri Nikku
            Reporter:
            matt.boros@mongodb.com Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: