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

Investigate nested $unionWith regression

    • Type: Icon: Task Task
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Query Execution
    • 2

      The following workload has regressed: 

      union_with UnionWith.UnionWithThreeCollNestedNoOverlap -12.69541889 

      Here's the query:

      [{$unionWith: {   coll: "Collection1",  pipeline: [{$set: {integer: "$integer"}},   {$unionWith: {coll: "Collection2", pipeline: [{$set: {integer: "$integer"}}]}}]}}] 

      And the explain:

      > db.coll.explain().aggregate(   [{$unionWith: {   coll: "Collection1",  pipeline: [{$set: {integer: "$integer"}},   {$unionWith: {coll: "Collection2", pipeline: [{$set: {integer: "$integer"}}]}}]}}] )
      {
          "explainVersion" : "2",
          "stages" : [
              {
                  "$cursor" : {
                      "queryPlanner" : {
                          "namespace" : "db.coll",
                          "indexFilterSet" : false,
                          "parsedQuery" : {                    },
                          "queryHash" : "2A5DDA38",
                          "planCacheKey" : "7B89F552",
                          "maxIndexedOrSolutionsReached" : false,
                          "maxIndexedAndSolutionsReached" : false,
                          "maxScansToExplodeReached" : false,
                          "winningPlan" : {
                              "queryPlan" : {
                                  "stage" : "COLLSCAN",
                                  "planNodeId" : 1,
                                  "filter" : {                            },
                                  "direction" : "forward"
                              },
                              "slotBasedPlan" : {
                                  "slots" : "$$RESULT=s4 env: { s3 = 1673294711490 (NOW), s1 = TimeZoneDatabase(Asia/Jayapura...Australia/Hobart) (timeZoneDB), s2 = Nothing (SEARCH_META) }",
                                  "stages" : "[1] scan s4 s5 none none none none [] @\"8921938a-f5dc-4556-896b-1b9381e9f125\" true false "
                              }
                          },
                          "rejectedPlans" : [ ]
                      }
                  }
              },
              {
                  "$unionWith" : {
                      "coll" : "Collection1",
                      "pipeline" : [
                          {
                              "$cursor" : {
                                  "queryPlanner" : {
                                      "namespace" : "db.Collection1",
                                      "indexFilterSet" : false,
                                      "parsedQuery" : {                                },
                                      "queryHash" : "2A5DDA38",
                                      "planCacheKey" : "6E411424",
                                      "maxIndexedOrSolutionsReached" : false,
                                      "maxIndexedAndSolutionsReached" : false,
                                      "maxScansToExplodeReached" : false,
                                      "winningPlan" : {
                                          "queryPlan" : {
                                              "stage" : "COLLSCAN",
                                              "planNodeId" : 1,
                                              "filter" : {                                        },
                                              "direction" : "forward"
                                          },
                                          "slotBasedPlan" : {
                                              "slots" : "$$RESULT=s4 env: { s3 = 1673294711490 (NOW), s1 = TimeZoneDatabase(Asia/Jayapura...Australia/Hobart) (timeZoneDB), s2 = Nothing (SEARCH_META) }",
                                              "stages" : "[1] scan s4 s5 none none none none [] @\"ebd072cd-19b2-4f47-8cdf-bcbccde6942c\" true false "
                                          }
                                      },
                                      "rejectedPlans" : [ ]
                                  }
                              }
                          },
                          {
                              "$set" : {
                                  "integer" : "$integer"
                              }
                          },
                          {
                              "$unionWith" : {
                                  "coll" : "Collection2",
                                  "pipeline" : [
                                      {
                                          "$cursor" : {
                                              "queryPlanner" : {
                                                  "namespace" : "db.Collection2",
                                                  "indexFilterSet" : false,
                                                  "parsedQuery" : {                                            },
                                                  "queryHash" : "2A5DDA38",
                                                  "planCacheKey" : "468B32E6",
                                                  "maxIndexedOrSolutionsReached" : false,
                                                  "maxIndexedAndSolutionsReached" : false,
                                                  "maxScansToExplodeReached" : false,
                                                  "winningPlan" : {
                                                      "queryPlan" : {
                                                          "stage" : "COLLSCAN",
                                                          "planNodeId" : 1,
                                                          "filter" : {                                                    },
                                                          "direction" : "forward"
                                                      },
                                                      "slotBasedPlan" : {
                                                          "slots" : "$$RESULT=s4 env: { s1 = TimeZoneDatabase(Asia/Jayapura...Australia/Hobart) (timeZoneDB), s2 = Nothing (SEARCH_META), s3 = 1673294711490 (NOW) }",
                                                          "stages" : "[1] scan s4 s5 none none none none [] @\"7744af4c-2b82-4ec9-8ed0-07a8ea62f0ef\" true false "
                                                      }
                                                  },
                                                  "rejectedPlans" : [ ]
                                              }
                                          }
                                      },
                                      {
                                          "$set" : {
                                              "integer" : "$integer"
                                          }
                                      }
                                  ]
                              }
                          }
                      ]
                  }
              }
          ],
          "serverInfo" : {
              "host" : "ip-10-122-15-159",
              "port" : 27017,
              "version" : "6.3.0-alpha-833-g14311b5",
              "gitVersion" : "14311b5b2491c609c7d1e08d13913410c2022afc"
          },
          "serverParameters" : {
              "internalQueryFacetBufferSizeBytes" : 104857600,
              "internalQueryFacetMaxOutputDocSizeBytes" : 104857600,
              "internalLookupStageIntermediateDocumentMaxSizeBytes" : 104857600,
              "internalDocumentSourceGroupMaxMemoryBytes" : 104857600,
              "internalQueryMaxBlockingSortMemoryUsageBytes" : 104857600,
              "internalQueryProhibitBlockingMergeOnMongoS" : 0,
              "internalQueryMaxAddToSetBytes" : 104857600,
              "internalDocumentSourceSetWindowFieldsMaxMemoryBytes" : 104857600,
              "internalQueryFrameworkControl" : "tryBonsai"
          },
          "command" : {
              "aggregate" : "coll",
              "pipeline" : [
                  {
                      "$unionWith" : {
                          "coll" : "Collection1",
                          "pipeline" : [
                              {
                                  "$set" : {
                                      "integer" : "$integer"
                                  }
                              },
                              {
                                  "$unionWith" : {
                                      "coll" : "Collection2",
                                      "pipeline" : [
                                          {
                                              "$set" : {
                                                  "integer" : "$integer"
                                              }
                                          }
                                      ]
                                  }
                              }
                          ]
                      }
                  }
              ],
              "explain" : true,
              "cursor" : {        },
              "lsid" : {
                  "id" : UUID("c5fa033f-f963-4fb1-b709-75c24ea632d4")
              },
              "$db" : "db"
          },
          "ok" : 1
      } 

      Ultimately it is 3 nested collections with some projections in the mix. 

            Assignee:
            ivan.fefer@mongodb.com Ivan Fefer
            Reporter:
            mihai.andrei@mongodb.com Mihai Andrei
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: