$lookup against sparse index

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In Mongodb 7.0, I started getting extraordinarily long query times for some aggregate queries with $lookup. Namely, if the aggregate query was looking up against a collection using a field that had a sparse index:

      document.student.createIndex(

      {'teacher_id': 1}

      , {
      partialFilterExpression: {'teacher_id': {
      $exists: true,
      }},
      });

      db.teacher.aggregate([{$lookup: {from: 'student', let:

      {teacherId: '$_id'}

      , pipeline: [{'$match': {'$expr': {$eq: ['$teacher_id', '$$teacherId']}}}], as: 'students'}}]);

      This is somewhat related to, but different from the following:
      https://www.mongodb.com/community/forums/t/conditional-lookup/3833/10
      https://jira.mongodb.org/browse/SERVER-44749

              Assignee:
              Rhea Thorne
              Reporter:
              Ben Rotz
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: