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

if count or match after lookup very slow

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

      aggregate query like below very slow [{
      "$lookup": {
      "from": "a" ,
      "let":

      { "item": "b" }

      ,
      "pipeline": [
      {
      "$match": {
      "$expr": {
      "$and":[

      {"$eq": [ "$_id", "$$item" ]}

      ]
      }
      }
      },

      { "$limit":1 }

      ],
      "as": "tmp_item"
      }
      },

      { "$count":"count"}

      ]
      I must put $count or $match after $lookup because of use lookup's results

            Assignee:
            Unassigned Unassigned
            Reporter:
            huzech@gmail.com George Wang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: