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

$lookup & $match performance improvement

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

      I am trying to use mongoDb aggregation pipeline to lookup other table and check if matched some of the attributes.

      my query is something like below (p.s. bigtable is sharded):

       db.bigtable.aggregate( [  
          {$lookup:{ from: "user", localField:
                     "user_code", foreignField: "code",as: "user"}},   
          {$match: {"user.country":"US" } }] )
      

      I have created index for bigtable.user_code, user.code & user.country. But the query is very very very slow. I tried explain it, it is COLLSCAN.

      It seems to me what using $match with foreign table's attribute, index is not supported and therefore, the query speed is very slow.

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            angusscli angus
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: