$lookup plans with no subpipeline and with subpipeline that is an empty array are not identical

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The documentation for $lookup says:

      To return all documents, specify an empty pipeline: []

      But he following two pipelines have different plans:

      db.part.aggregate([{ $lookup: { from: 'partsupp', localField: 'p_partkey', foreignField: 'ps_partkey', pipeline: [], as: 'partsupp' } }] );
      db.part.aggregate([{ $lookup: { from: 'partsupp', localField: 'p_partkey', foreignField: 'ps_partkey',               as: 'partsupp' } }, { $unwind: '$partsupp' }] );
      

      The plan where the pipeline argument is not present at all is a full-blown SBE join pipeline. The plan where the pipeline argument is an empty array is a single-line SBE table scan followed by a classic $lookup plan.

      My understanding is that the two queries are equivalent and therefore should produce equivalent plans.

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

              Created:
              Updated:
              Resolved: