Plan enumerator generates an AND_SORTED plan with two identical IXSCANs

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • ALL
    • Hide
      db.foo.drop();
      db.foo.createIndex({b: 1});
      
      db.foo.insert({a: 1, b: []});
      
      db.foo.aggregate([ { "$match": { "$and": [
      	{ "$or": [
      		{ "a": 2 },
      		{ "a": { "$ne": 14 } }
      		]
      	},
      	], "$or": [
      		{ "x": 11 },
      		{ "a": 6  }
      	],
      	"b": { "$all": [ 13, 13] }
      }}] ).explain().queryPlanner.rejectedPlans[1];
       
      Show
      db.foo.drop(); db.foo.createIndex({b: 1}); db.foo.insert({a: 1, b: []}); db.foo.aggregate([ { "$match" : { "$and" : [ { "$or" : [ { "a" : 2 }, { "a" : { "$ne" : 14 } } ] }, ], "$or" : [ { "x" : 11 }, { "a" : 6 } ], "b" : { "$all" : [ 13, 13] } }}] ).explain().queryPlanner.rejectedPlans[1];
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None

      The test case below generates the following plan where the two inputs to the `AND_SORTED` are identical. The other two plans for this pipeline are affected by SERVER-89110

      inputStage: {
          stage: 'AND_SORTED',
          costEstimate: 0.00011999999999999999,
          cardinalityEstimate: 0,
          estimatesMetadata: { ceSource: 'Code' },
          inputStages: [
            {
              stage: 'IXSCAN',
              costEstimate: 0.000009999999999999999,
              cardinalityEstimate: 0,
              numKeysEstimate: 0,
              estimatesMetadata: { ceSource: 'Sampling' },
              keyPattern: { b: 1 },
              indexName: 'b_1',
              isMultiKey: true,
              multiKeyPaths: { b: [ 'b' ] },
              isUnique: false,
              isSparse: false,
              isPartial: false,
              indexVersion: 2,
              direction: 'forward',
              indexBounds: { b: [ '[13, 13]' ] }
            },
            {
              stage: 'IXSCAN',
              costEstimate: 0.000009999999999999999,
              cardinalityEstimate: 0,
              numKeysEstimate: 0,
              estimatesMetadata: { ceSource: 'Sampling' },
              keyPattern: { b: 1 },
              indexName: 'b_1',
              isMultiKey: true,
              multiKeyPaths: { b: [ 'b' ] },
              isUnique: false,
              isSparse: false,
              isPartial: false,
              indexVersion: 2,
              direction: 'forward',
              indexBounds: { b: [ '[13, 13]' ] }
            }
          ]
        }
       

            Assignee:
            Unassigned
            Reporter:
            Philip Stoev
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: