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

$lookup against sparse index

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

      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@mongodb.com Rhea Thorne
            Reporter:
            ben@ethika.com Ben Rotz
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: