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

Combined $match, $expr in aggregation not using indexes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 3.6.0, 3.6.2
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Make sure the collection has an indexed property (ExternalId in this example). The query

      {{db.collection.aggregate([
      {
      "$match": {"$expr": {"$eq": ["FullProposalId","123456"]}}
      }
      ],

      {explain:true}

      )}}

      shows a COLLSCAN fetch stage
      while the simple aggregation below (that cannot be used in lookups with "lets"):
      {{db.collection.aggregate([
      {
      "$match":

      {"ExternalId":"123456"}

      }
      ],

      {explain:true}

      )

      }}
      shows an IXSCAN stage (as epxected)

      Show
      Make sure the collection has an indexed property (ExternalId in this example). The query {{db.collection.aggregate([ { "$match": {"$expr": {"$eq": ["FullProposalId","123456"] }} } ], {explain:true} )}} shows a COLLSCAN fetch stage while the simple aggregation below (that cannot be used in lookups with "lets"): {{db.collection.aggregate([ { "$match": {"ExternalId":"123456"} } ], {explain:true} ) }} shows an IXSCAN stage (as epxected)

      Description

      While using $lookup stages in aggregation pipelines using the new "Multiple Join Conditions", which requires $expr commands, the lookup uses COLLSCAN instead of indexes to fetch the destination values.

      In fact this seems to be a problem with the "$expr" command and not the $lookup phase itself. (see steps to reproduce)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: