diff --git a/jstests/core/query/explain/internal_query_explain_size_threshold_bytes.js b/jstests/core/query/explain/internal_query_explain_size_threshold_bytes.js index 8dcfa3f4e8d..283231d503a 100644 --- a/jstests/core/query/explain/internal_query_explain_size_threshold_bytes.js +++ b/jstests/core/query/explain/internal_query_explain_size_threshold_bytes.js @@ -55,7 +55,7 @@ const original = assert.commandWorked(db.adminCommand({getParameter: 1, "interna try { // Increase explain threshold step-by-step. - for (let size = 350; ; size++) { + for (let size = 410; ; size++) { if (!checkSbeRestrictedOrFullyEnabled(db)) { // Test is SBE-only. break; @@ -73,11 +73,11 @@ try { .aggregate([{$match: {"$or": orClauses}}, {$group: {_id: "$_id"}}, {$project: {_id: 1, a: 0}}]); // Test is SBE-only. Assert the query used SBE as expected. assert(getWarnings(explain).length > 0 || getEngine(explain) === "sbe"); - jsTestLog("Checking explain"); + jsTest.log.info("Checking explain"); let winningPlan = getQueryPlanner(explain).winningPlan; let queryPlan = winningPlan.queryPlan; let slotBasedPlan = winningPlan.slotBasedPlan; - jsTestLog({ + jsTest.log.info({ "size": size, "Object.bsonsize(winningPlan)": Object.bsonsize(winningPlan), "winningPlan": winningPlan, diff --git a/jstests/query_golden/expected_output/cached_partial_index_plan_not_reused_for_ineligible_query.md b/jstests/query_golden/expected_output/cached_partial_index_plan_not_reused_for_ineligible_query.md index dcc81454960..6e08a8d9d15 100644 --- a/jstests/query_golden/expected_output/cached_partial_index_plan_not_reused_for_ineligible_query.md +++ b/jstests/query_golden/expected_output/cached_partial_index_plan_not_reused_for_ineligible_query.md @@ -144,8 +144,10 @@ Creating Index "$lte" : 5 } }, + "nss" : "test.cached_partial_index_plan_not_reused_for_ineligible_query_md", "inputStage" : { "stage" : "IXSCAN", + "nss" : "test.cached_partial_index_plan_not_reused_for_ineligible_query_md", "keyPattern" : { "a" : 1 }, diff --git a/jstests/query_golden/expected_output/expr_in_rewrite.md b/jstests/query_golden/expected_output/expr_in_rewrite.md index 55d135938b8..682d0341352 100644 --- a/jstests/query_golden/expected_output/expr_in_rewrite.md +++ b/jstests/query_golden/expected_output/expr_in_rewrite.md @@ -38,6 +38,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -79,6 +80,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -101,6 +103,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -146,6 +149,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -195,6 +199,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -217,6 +222,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -260,6 +266,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -307,6 +314,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -330,6 +338,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -376,6 +385,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -428,6 +438,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -451,6 +462,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -497,6 +509,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -549,6 +562,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -572,6 +586,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -617,6 +632,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -668,6 +684,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -691,6 +708,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -738,6 +756,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -792,6 +811,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -815,6 +835,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -863,6 +884,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -919,6 +941,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -942,6 +965,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -990,6 +1014,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1047,6 +1072,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1070,6 +1096,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1119,6 +1146,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1178,6 +1206,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1201,6 +1230,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1246,6 +1276,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1286,6 +1317,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1308,6 +1340,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1355,6 +1388,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1410,6 +1444,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1433,6 +1468,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1478,6 +1514,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1518,6 +1555,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1540,6 +1578,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1587,6 +1626,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1642,6 +1682,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1665,6 +1706,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1711,6 +1753,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1752,6 +1795,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1774,6 +1818,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1821,6 +1866,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1876,6 +1922,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1899,6 +1946,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1942,6 +1990,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1980,6 +2029,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2002,6 +2052,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2045,6 +2096,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2083,6 +2135,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2105,6 +2158,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2149,6 +2203,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2188,6 +2243,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2210,6 +2266,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2255,6 +2312,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2306,6 +2364,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2329,6 +2388,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2374,6 +2434,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2425,6 +2486,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2448,6 +2510,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2493,6 +2556,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2544,6 +2608,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2567,6 +2632,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2612,6 +2678,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2663,6 +2730,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2686,6 +2754,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2731,6 +2800,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2782,6 +2852,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2805,6 +2876,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2850,6 +2922,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2901,6 +2974,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2924,6 +2998,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2974,6 +3049,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3019,6 +3095,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3041,6 +3118,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3101,6 +3179,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3156,6 +3235,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3179,6 +3259,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3251,6 +3332,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3344,6 +3426,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3427,6 +3510,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3505,6 +3589,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3528,6 +3613,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3597,6 +3683,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3661,6 +3748,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3684,6 +3772,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3728,6 +3817,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3767,6 +3857,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3790,6 +3881,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3835,6 +3927,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3886,6 +3979,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3910,6 +4004,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3957,6 +4052,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4012,6 +4108,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4036,6 +4133,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4079,6 +4177,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4126,6 +4225,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4150,6 +4250,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4195,6 +4296,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4246,6 +4348,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4270,6 +4373,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4315,6 +4419,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4355,6 +4460,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4378,6 +4484,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4425,6 +4532,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4480,6 +4588,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4504,6 +4613,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4547,6 +4657,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4594,6 +4705,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4617,6 +4729,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4662,6 +4775,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4713,6 +4827,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4737,6 +4852,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/base_coll_reorder.md b/jstests/query_golden/expected_output/featureFlagSbeFull/base_coll_reorder.md index 1e4f7c0bcf6..1f35bc4fa41 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/base_coll_reorder.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/base_coll_reorder.md @@ -63,6 +63,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" }, "localField" : "a", @@ -166,6 +167,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" }, "localField" : "a", @@ -264,6 +266,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" }, "localField" : "base", diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/basic_joins.md b/jstests/query_golden/expected_output/featureFlagSbeFull/basic_joins.md index 14a64ca7296..c4a97069d46 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/basic_joins.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/basic_joins.md @@ -55,6 +55,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -123,6 +124,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -130,6 +132,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -145,6 +148,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -209,6 +213,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -218,6 +223,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -225,6 +231,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -299,6 +306,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -306,6 +314,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -321,6 +330,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -387,6 +397,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -394,6 +405,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -409,6 +421,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -475,6 +488,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -482,6 +496,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -497,6 +512,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -563,6 +579,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -570,6 +587,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -585,6 +603,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -651,6 +670,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -658,6 +678,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -673,6 +694,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -687,6 +709,105 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "2312073BEBB7A5E1754E2D03D9CB40B75C126DBF60867D4639E7E281C9E3DFAC", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 6, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 2. Basic example with two joins and suffix ### No join opt ### Pipeline @@ -745,6 +866,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -831,6 +953,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -845,6 +968,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -860,6 +984,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -946,6 +1071,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -956,6 +1082,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -970,6 +1097,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1067,6 +1195,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1081,6 +1210,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1096,6 +1226,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1184,6 +1315,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1192,6 +1324,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1214,6 +1347,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1302,6 +1436,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1310,6 +1445,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1332,6 +1468,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1420,6 +1557,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1428,6 +1566,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1450,6 +1589,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1538,6 +1678,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1546,6 +1687,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1568,6 +1710,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1603,6 +1746,135 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$y.b" + } +] +``` +### Results +```json +{ "_id" : "bar", "count" : 6 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "8E0DF14D3DA69D8B1CF0361E869369F9C5E5F2F2A5D81998E6800BDA4F997B57", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$y.b", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 3. Basic example with referencing field from previous lookup ### No join opt ### Pipeline @@ -1658,6 +1930,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -1724,6 +1997,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -1731,6 +2005,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1746,6 +2021,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -1808,6 +2084,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -1817,6 +2094,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -1824,6 +2102,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1896,6 +2175,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -1903,6 +2183,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1918,6 +2199,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -1982,6 +2264,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1989,6 +2272,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -2004,6 +2288,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -2068,6 +2353,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -2075,6 +2361,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -2090,6 +2377,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -2154,6 +2442,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -2161,6 +2450,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2176,6 +2466,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -2240,6 +2531,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -2247,6 +2539,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2262,6 +2555,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -2276,6 +2570,95 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 0, "a" : 1, "b" : "foo", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DC5CAF413E9B6B8B5E8B2D3FB91E4D546524BF2707BBE30472D5CA8E12F6637E", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "z", + "rightEmbeddingField" : "x", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 5, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 4. Basic example with 3 joins & subsequent join referencing fields from previous lookups ### No join opt ### Pipeline @@ -2348,6 +2731,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -2434,6 +2818,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2441,6 +2826,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2456,6 +2842,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2471,6 +2858,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -2546,6 +2934,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -2555,6 +2944,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -2564,6 +2954,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2571,6 +2962,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2662,6 +3054,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -2673,6 +3066,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2680,6 +3074,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2695,6 +3090,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2782,6 +3178,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2789,6 +3186,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2804,6 +3202,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -2819,6 +3218,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2898,6 +3298,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2905,6 +3306,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2920,6 +3322,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -2935,6 +3338,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3014,6 +3418,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3021,6 +3426,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -3036,6 +3442,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3051,6 +3458,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3130,6 +3538,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3137,6 +3546,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -3152,6 +3562,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3167,6 +3578,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3181,6 +3593,134 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DD24FFAE1F16C6C1F5B03939E0C642A797120A2585058C72554C9649BEA427AB", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "y", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 5. Basic example with 3 joins & subsequent join referencing nested paths ### No join opt ### Pipeline @@ -3248,6 +3788,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -3329,6 +3870,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3336,6 +3878,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3351,6 +3894,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -3366,6 +3910,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3436,6 +3981,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3445,6 +3991,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -3454,6 +4001,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3461,6 +4009,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3547,6 +4096,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3558,6 +4108,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3565,6 +4116,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3580,6 +4132,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -3662,6 +4215,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3669,6 +4223,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3684,6 +4239,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -3699,6 +4255,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3773,6 +4330,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3780,6 +4338,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3795,6 +4354,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -3810,6 +4370,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3884,6 +4445,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3891,6 +4453,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -3906,6 +4469,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3921,6 +4485,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3995,6 +4560,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -4002,6 +4568,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -4017,6 +4584,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4032,6 +4600,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -4046,3 +4615,118 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "w.y", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$w.y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "k.y.z", + "localField" : "w.y.d", + "foreignField" : "d" + } + }, + { + "$unwind" : "$k.y.z" + } +] +``` +### Results +```json +{ "_id" : 2, "a" : 2, "b" : "bar", "k" : { "y" : { "z" : { "_id" : 0, "b" : "bar", "d" : 2 } } }, "w" : { "y" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } }, "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "9226A4FAA10C8790B27D9B5B865D46D0C58179A837F014E6289A34A6EBE76420", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "w.y", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "w.y.d = d" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "k.y.z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md b/jstests/query_golden/expected_output/featureFlagSbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md index d2bbea0b1cd..60906beae47 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md @@ -144,9 +144,11 @@ Creating Index "$lte" : 5 } }, + "nss" : "test.cached_partial_index_plan_not_reused_for_ineligible_query_md", "inputStage" : { "stage" : "IXSCAN", "planNodeId" : 1, + "nss" : "test.cached_partial_index_plan_not_reused_for_ineligible_query_md", "keyPattern" : { "a" : 1 }, diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_aggregation_multiplanning.md b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_aggregation_multiplanning.md index 21d5a3d41c7..be4bc87f255 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_aggregation_multiplanning.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_aggregation_multiplanning.md @@ -2025,6 +2025,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2328,6 +2329,7 @@ Execution Engine: sbe "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2394,6 +2396,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -2900,6 +2903,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2920,6 +2924,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -2957,6 +2962,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2977,6 +2983,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3014,6 +3021,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3034,6 +3042,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3076,6 +3085,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3096,6 +3106,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3215,6 +3226,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3235,6 +3247,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3309,6 +3322,7 @@ Execution Engine: sbe "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3329,6 +3343,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3400,6 +3415,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3425,6 +3441,7 @@ Execution Engine: sbe "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3506,6 +3523,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-2", "stage" : "IXSCAN" } ] @@ -3673,6 +3691,7 @@ Execution Engine: classic "$gt" : 0 } }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "FETCH" }, { @@ -3698,6 +3717,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "IXSCAN" } ] @@ -3886,6 +3906,7 @@ Execution Engine: sbe "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4055,6 +4076,7 @@ Execution Engine: sbe "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4191,6 +4213,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4218,6 +4241,7 @@ Execution Engine: sbe ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4249,6 +4273,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -4296,6 +4321,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_command_multiplanning.md b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_command_multiplanning.md index f4ec46357ae..212717be244 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_command_multiplanning.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_command_multiplanning.md @@ -75,6 +75,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -100,6 +101,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -145,6 +147,7 @@ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -167,6 +170,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -253,6 +257,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -278,6 +283,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -798,6 +804,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -823,6 +830,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -865,6 +873,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -890,6 +899,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -927,6 +937,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -952,6 +963,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -994,6 +1006,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1019,6 +1032,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1061,6 +1075,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1086,6 +1101,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1128,6 +1144,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1153,6 +1170,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1371,6 +1389,7 @@ "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1399,6 +1418,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1424,6 +1444,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1456,6 +1477,7 @@ "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1484,6 +1506,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1515,6 +1538,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1537,6 +1561,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1557,6 +1582,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1567,6 +1593,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1592,6 +1619,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1687,6 +1715,7 @@ "$lt" : 105 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1707,6 +1736,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1718,6 +1748,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1743,6 +1774,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1776,6 +1808,7 @@ "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1799,6 +1832,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1807,6 +1841,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1832,6 +1867,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1902,6 +1938,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1922,6 +1959,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1954,6 +1992,7 @@ } ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_index_eligibility.md b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_index_eligibility.md index 2dd0056e142..551c70650ad 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_index_eligibility.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_index_eligibility.md @@ -34,6 +34,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -61,6 +62,7 @@ Execution Engine: sbe ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] @@ -190,6 +192,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -348,6 +351,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -387,6 +391,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -443,6 +448,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -728,6 +734,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -932,6 +939,7 @@ Execution Engine: classic "$lt" : 3 } }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -949,6 +957,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -974,6 +983,7 @@ Execution Engine: classic "$_path" : [ ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_query_planner.md b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_query_planner.md index 8c00ea6e05b..dcd30eeda12 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_query_planner.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_query_planner.md @@ -209,6 +209,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] @@ -259,6 +260,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_query_planner_md", "stage" : "FETCH" }, { @@ -279,6 +281,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_query_planner_md", "stage" : "IXSCAN" } ] @@ -374,6 +377,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_scan.md b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_scan.md index 8f97c236a4e..3b10c81beec 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_scan.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/distinct_scan.md @@ -13,6 +13,7 @@ "filter" : { }, + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -47,6 +48,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -691,6 +693,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -711,6 +714,7 @@ Execution Engine: classic "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] @@ -749,6 +753,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -769,6 +774,7 @@ Execution Engine: sbe "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/featureFlagSbeFull/expr_in_rewrite.md b/jstests/query_golden/expected_output/featureFlagSbeFull/expr_in_rewrite.md index ca7317bcabe..8578bdb4955 100644 --- a/jstests/query_golden/expected_output/featureFlagSbeFull/expr_in_rewrite.md +++ b/jstests/query_golden/expected_output/featureFlagSbeFull/expr_in_rewrite.md @@ -38,6 +38,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -79,6 +80,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -101,6 +103,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -146,6 +149,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -195,6 +199,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -217,6 +222,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -260,6 +266,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -307,6 +314,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -330,6 +338,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -376,6 +385,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -428,6 +438,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -451,6 +462,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -497,6 +509,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -549,6 +562,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -572,6 +586,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -617,6 +632,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -668,6 +684,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -691,6 +708,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -738,6 +756,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -792,6 +811,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -815,6 +835,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -863,6 +884,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -919,6 +941,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -942,6 +965,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -990,6 +1014,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1047,6 +1072,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1070,6 +1096,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1119,6 +1146,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1178,6 +1206,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1201,6 +1230,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1246,6 +1276,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1286,6 +1317,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1308,6 +1340,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1355,6 +1388,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1410,6 +1444,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1433,6 +1468,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1478,6 +1514,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1518,6 +1555,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1540,6 +1578,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1587,6 +1626,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1642,6 +1682,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1665,6 +1706,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1711,6 +1753,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1752,6 +1795,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1774,6 +1818,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1821,6 +1866,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1876,6 +1922,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1899,6 +1946,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1942,6 +1990,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1980,6 +2029,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2002,6 +2052,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2045,6 +2096,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2083,6 +2135,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2105,6 +2158,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2149,6 +2203,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2188,6 +2243,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2210,6 +2266,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2255,6 +2312,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2306,6 +2364,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2329,6 +2388,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2374,6 +2434,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2425,6 +2486,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2448,6 +2510,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2493,6 +2556,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2544,6 +2608,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2567,6 +2632,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2612,6 +2678,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2663,6 +2730,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2686,6 +2754,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2731,6 +2800,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2782,6 +2852,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2805,6 +2876,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2850,6 +2922,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2901,6 +2974,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2924,6 +2998,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2974,6 +3049,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3019,6 +3095,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3041,6 +3118,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3101,6 +3179,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3156,6 +3235,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3179,6 +3259,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3251,6 +3332,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3344,6 +3426,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3427,6 +3510,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3505,6 +3589,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3528,6 +3613,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3597,6 +3683,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3661,6 +3748,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3684,6 +3772,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3728,6 +3817,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3767,6 +3857,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3790,6 +3881,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3835,6 +3927,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3886,6 +3979,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3910,6 +4004,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3957,6 +4052,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4012,6 +4108,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4036,6 +4133,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4079,6 +4177,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4126,6 +4225,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4150,6 +4250,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4195,6 +4296,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4246,6 +4348,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4270,6 +4373,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4315,6 +4419,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4355,6 +4460,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4378,6 +4484,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4425,6 +4532,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4480,6 +4588,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4504,6 +4613,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4547,6 +4657,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4594,6 +4705,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4617,6 +4729,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4662,6 +4775,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4713,6 +4827,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4737,6 +4852,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/large_in_with_indexes.md b/jstests/query_golden/expected_output/large_in_with_indexes.md index 3c54e36b14e..f5d4b6104dc 100644 --- a/jstests/query_golden/expected_output/large_in_with_indexes.md +++ b/jstests/query_golden/expected_output/large_in_with_indexes.md @@ -4,1710 +4,350 @@ setting random seed: 1 ### Expected plan Note: expecting an IXSCAN on _id_1_rd_1_ard_1 ```json -{ - "winningPlan" : [ - { - "stage" : "FETCH" +[ + { + "stage" : "FETCH", + "nss" : "test.large_in_with_indexes" + }, + { + "stage" : "SORT", + "sortPattern" : { + "ard" : 1 }, - { - "stage" : "SORT", - "sortPattern" : { - "ard" : 1 - }, - "memLimit" : 104857600, - "type" : "default" + "memLimit" : 104857600, + "type" : "default" + }, + { + "stage" : "IXSCAN", + "nss" : "test.large_in_with_indexes", + "keyPattern" : { + "_id" : 1, + "rd" : 1, + "ard" : 1 }, - { - "stage" : "IXSCAN", - "keyPattern" : { - "_id" : 1, - "rd" : 1, - "ard" : 1 - }, - "indexName" : "_id_1_rd_1_ard_1", - "isMultiKey" : false, - "multiKeyPaths" : { - "_id" : [ ], - "rd" : [ ], - "ard" : [ ] - }, - "isUnique" : false, - "isSparse" : false, - "isPartial" : false, - "direction" : "forward", - "indexBounds" : { - "_id" : [ - "[355.0, 355.0]", - "[587.0, 587.0]", - "[1310.0, 1310.0]", - "[1362.0, 1362.0]", - "[2483.0, 2483.0]", - "[3190.0, 3190.0]", - "[3318.0, 3318.0]", - "[3650.0, 3650.0]", - "[4543.0, 4543.0]", - "[4571.0, 4571.0]", - "[4578.0, 4578.0]", - "[4816.0, 4816.0]", - "[4913.0, 4913.0]", - "[5045.0, 5045.0]", - "[5459.0, 5459.0]", - "[5735.0, 5735.0]", - "[6596.0, 6596.0]", - "[6818.0, 6818.0]", - "[6870.0, 6870.0]", - "[7074.0, 7074.0]", - "[7090.0, 7090.0]", - "[7185.0, 7185.0]", - "[7361.0, 7361.0]", - "[7886.0, 7886.0]", - "[8042.0, 8042.0]", - "[8381.0, 8381.0]", - "[8551.0, 8551.0]", - "[9094.0, 9094.0]", - "[9114.0, 9114.0]", - "[9709.0, 9709.0]", - "[9909.0, 9909.0]", - "[10018.0, 10018.0]", - "[10624.0, 10624.0]", - "[10666.0, 10666.0]", - "[11022.0, 11022.0]", - "[11489.0, 11489.0]", - "[11646.0, 11646.0]", - "[11747.0, 11747.0]", - "[12240.0, 12240.0]", - "[12511.0, 12511.0]", - "[12623.0, 12623.0]", - "[12842.0, 12842.0]", - "[12961.0, 12961.0]", - "[14074.0, 14074.0]", - "[14370.0, 14370.0]", - "[15224.0, 15224.0]", - "[15347.0, 15347.0]", - "[15440.0, 15440.0]", - "[15549.0, 15549.0]", - "[16010.0, 16010.0]", - "[16535.0, 16535.0]", - "[16917.0, 16917.0]", - "[17013.0, 17013.0]", - "[17155.0, 17155.0]", - "[17762.0, 17762.0]", - "[17838.0, 17838.0]", - "[18208.0, 18208.0]", - "[18226.0, 18226.0]", - "[19339.0, 19339.0]", - "[19513.0, 19513.0]", - "[19951.0, 19951.0]", - "[19965.0, 19965.0]", - "[20119.0, 20119.0]", - "[20775.0, 20775.0]", - "[20778.0, 20778.0]", - "[20876.0, 20876.0]", - "[21423.0, 21423.0]", - "[21632.0, 21632.0]", - "[22018.0, 22018.0]", - "[22323.0, 22323.0]", - "[22354.0, 22354.0]", - "[22420.0, 22420.0]", - "[22431.0, 22431.0]", - "[22530.0, 22530.0]", - "[22993.0, 22993.0]", - "[23382.0, 23382.0]", - "[23406.0, 23406.0]", - "[23788.0, 23788.0]", - "[23817.0, 23817.0]", - "[23840.0, 23840.0]", - "[23842.0, 23842.0]", - "[24547.0, 24547.0]", - "[25178.0, 25178.0]", - "[25213.0, 25213.0]", - "[25741.0, 25741.0]", - "[25779.0, 25779.0]", - "[25984.0, 25984.0]", - "[26403.0, 26403.0]", - "[26470.0, 26470.0]", - "[26480.0, 26480.0]", - "[27615.0, 27615.0]", - "[27675.0, 27675.0]", - "[27724.0, 27724.0]", - "[27927.0, 27927.0]", - "[28126.0, 28126.0]", - "[28244.0, 28244.0]", - "[28600.0, 28600.0]", - "[29087.0, 29087.0]", - "[29301.0, 29301.0]", - "[29604.0, 29604.0]", - "[30138.0, 30138.0]", - "[31436.0, 31436.0]", - "[31452.0, 31452.0]", - "[31867.0, 31867.0]", - "[32273.0, 32273.0]", - "[32294.0, 32294.0]", - "[32676.0, 32676.0]", - "[32744.0, 32744.0]", - "[33479.0, 33479.0]", - "[33673.0, 33673.0]", - "[33937.0, 33937.0]", - "[34051.0, 34051.0]", - "[34642.0, 34642.0]", - "[35221.0, 35221.0]", - "[35871.0, 35871.0]", - "[36712.0, 36712.0]", - "[37259.0, 37259.0]", - "[37334.0, 37334.0]", - "[37981.0, 37981.0]", - "[38125.0, 38125.0]", - "[38419.0, 38419.0]", - "[38547.0, 38547.0]", - "[38982.0, 38982.0]", - "[39111.0, 39111.0]", - "[39888.0, 39888.0]", - "[40056.0, 40056.0]", - "[40147.0, 40147.0]", - "[40933.0, 40933.0]", - "[41204.0, 41204.0]", - "[41313.0, 41313.0]", - "[41478.0, 41478.0]", - "[41802.0, 41802.0]", - "[42450.0, 42450.0]", - "[42673.0, 42673.0]", - "[42701.0, 42701.0]", - "[42802.0, 42802.0]", - "[43347.0, 43347.0]", - "[44046.0, 44046.0]", - "[44650.0, 44650.0]", - "[45046.0, 45046.0]", - "[45308.0, 45308.0]", - "[45551.0, 45551.0]", - "[45663.0, 45663.0]", - "[45912.0, 45912.0]", - "[47410.0, 47410.0]", - "[47818.0, 47818.0]", - "[48700.0, 48700.0]", - "[48907.0, 48907.0]", - "[49104.0, 49104.0]", - "[49784.0, 49784.0]", - "[50218.0, 50218.0]", - "[50383.0, 50383.0]", - "[50570.0, 50570.0]", - "[50947.0, 50947.0]", - "[51683.0, 51683.0]", - "[51800.0, 51800.0]", - "[52059.0, 52059.0]", - "[53930.0, 53930.0]", - "[55068.0, 55068.0]", - "[55390.0, 55390.0]", - "[55395.0, 55395.0]", - "[55502.0, 55502.0]", - "[56037.0, 56037.0]", - "[56241.0, 56241.0]", - "[56524.0, 56524.0]", - "[56666.0, 56666.0]", - "[56708.0, 56708.0]", - "[56961.0, 56961.0]", - "[56962.0, 56962.0]", - "[58030.0, 58030.0]", - "[59577.0, 59577.0]", - "[59998.0, 59998.0]", - "[60085.0, 60085.0]", - "[60395.0, 60395.0]", - "[60882.0, 60882.0]", - "[60916.0, 60916.0]", - "[61539.0, 61539.0]", - "[61612.0, 61612.0]", - "[62114.0, 62114.0]", - "[62136.0, 62136.0]", - "[62318.0, 62318.0]", - "[62461.0, 62461.0]", - "[62827.0, 62827.0]", - "[63360.0, 63360.0]", - "[63695.0, 63695.0]", - "[63952.0, 63952.0]", - "[63995.0, 63995.0]", - "[64238.0, 64238.0]", - "[64336.0, 64336.0]", - "[65031.0, 65031.0]", - "[65583.0, 65583.0]", - "[65688.0, 65688.0]", - "[65696.0, 65696.0]", - "[65880.0, 65880.0]", - "[66943.0, 66943.0]", - "[67212.0, 67212.0]", - "[67219.0, 67219.0]", - "[67476.0, 67476.0]", - "[67654.0, 67654.0]", - "[67818.0, 67818.0]", - "[67936.0, 67936.0]", - "[67942.0, 67942.0]", - "[68332.0, 68332.0]", - "[68916.0, 68916.0]", - "[69474.0, 69474.0]", - "[69516.0, 69516.0]", - "[69727.0, 69727.0]", - "[69973.0, 69973.0]", - "[70024.0, 70024.0]", - "[70721.0, 70721.0]", - "[71479.0, 71479.0]", - "[71862.0, 71862.0]", - "[72293.0, 72293.0]", - "[73304.0, 73304.0]", - "[73323.0, 73323.0]", - "[73497.0, 73497.0]", - "[73505.0, 73505.0]", - "[73700.0, 73700.0]", - "[74041.0, 74041.0]", - "[74089.0, 74089.0]", - "[74367.0, 74367.0]", - "[75453.0, 75453.0]", - "[76167.0, 76167.0]", - "[76422.0, 76422.0]", - "[77032.0, 77032.0]", - "[77574.0, 77574.0]", - "[77842.0, 77842.0]", - "[78306.0, 78306.0]", - "[79272.0, 79272.0]", - "[79411.0, 79411.0]", - "[79451.0, 79451.0]", - "[79588.0, 79588.0]", - "[79991.0, 79991.0]", - "[80258.0, 80258.0]", - "[80842.0, 80842.0]", - "[80967.0, 80967.0]", - "[81204.0, 81204.0]", - "[81807.0, 81807.0]", - "[81923.0, 81923.0]", - "[82209.0, 82209.0]", - "[82573.0, 82573.0]", - "[82620.0, 82620.0]", - "[82636.0, 82636.0]", - "[82691.0, 82691.0]", - "[82837.0, 82837.0]", - "[83740.0, 83740.0]", - "[83851.0, 83851.0]", - "[84237.0, 84237.0]", - "[84301.0, 84301.0]", - "[84882.0, 84882.0]", - "[85334.0, 85334.0]", - "[85405.0, 85405.0]", - "[85606.0, 85606.0]", - "[86108.0, 86108.0]", - "[86311.0, 86311.0]", - "[87001.0, 87001.0]", - "[87243.0, 87243.0]", - "[87686.0, 87686.0]", - "[87903.0, 87903.0]", - "[88050.0, 88050.0]", - "[88064.0, 88064.0]", - "[88138.0, 88138.0]", - "[88307.0, 88307.0]", - "[88590.0, 88590.0]", - "[88964.0, 88964.0]", - "[89140.0, 89140.0]", - "[89167.0, 89167.0]", - "[89479.0, 89479.0]", - "[89847.0, 89847.0]", - "[90025.0, 90025.0]", - "[90056.0, 90056.0]", - "[90465.0, 90465.0]", - "[90466.0, 90466.0]", - "[90607.0, 90607.0]", - "[91120.0, 91120.0]", - "[91213.0, 91213.0]", - "[91271.0, 91271.0]", - "[91809.0, 91809.0]", - "[91830.0, 91830.0]", - "[92313.0, 92313.0]", - "[92892.0, 92892.0]", - "[92940.0, 92940.0]", - "[93536.0, 93536.0]", - "[93868.0, 93868.0]", - "[94144.0, 94144.0]", - "[94203.0, 94203.0]", - "[94896.0, 94896.0]", - "[95156.0, 95156.0]", - "[95169.0, 95169.0]", - "[95371.0, 95371.0]", - "[95955.0, 95955.0]", - "[96385.0, 96385.0]", - "[96391.0, 96391.0]", - "[96414.0, 96414.0]", - "[96626.0, 96626.0]", - "[97294.0, 97294.0]", - "[97504.0, 97504.0]", - "[98114.0, 98114.0]", - "[98426.0, 98426.0]", - "[98442.0, 98442.0]" - ], - "rd" : [ - "[7.0, inf]" - ], - "ard" : [ - "[MinKey, MaxKey]" - ] - } + "indexName" : "_id_1_rd_1_ard_1", + "isMultiKey" : false, + "multiKeyPaths" : { + "_id" : [ ], + "rd" : [ ], + "ard" : [ ] + }, + "isUnique" : false, + "isSparse" : false, + "isPartial" : false, + "direction" : "forward", + "indexBounds" : { + "_id" : [ + "[355.0, 355.0]", + "[587.0, 587.0]", + "[1310.0, 1310.0]", + "[1362.0, 1362.0]", + "[2483.0, 2483.0]", + "[3190.0, 3190.0]", + "[3318.0, 3318.0]", + "[3650.0, 3650.0]", + "[4543.0, 4543.0]", + "[4571.0, 4571.0]", + "[4578.0, 4578.0]", + "[4816.0, 4816.0]", + "[4913.0, 4913.0]", + "[5045.0, 5045.0]", + "[5459.0, 5459.0]", + "[5735.0, 5735.0]", + "[6596.0, 6596.0]", + "[6818.0, 6818.0]", + "[6870.0, 6870.0]", + "[7074.0, 7074.0]", + "[7090.0, 7090.0]", + "[7185.0, 7185.0]", + "[7361.0, 7361.0]", + "[7886.0, 7886.0]", + "[8042.0, 8042.0]", + "[8381.0, 8381.0]", + "[8551.0, 8551.0]", + "[9094.0, 9094.0]", + "[9114.0, 9114.0]", + "[9709.0, 9709.0]", + "[9909.0, 9909.0]", + "[10018.0, 10018.0]", + "[10624.0, 10624.0]", + "[10666.0, 10666.0]", + "[11022.0, 11022.0]", + "[11489.0, 11489.0]", + "[11646.0, 11646.0]", + "[11747.0, 11747.0]", + "[12240.0, 12240.0]", + "[12511.0, 12511.0]", + "[12623.0, 12623.0]", + "[12842.0, 12842.0]", + "[12961.0, 12961.0]", + "[14074.0, 14074.0]", + "[14370.0, 14370.0]", + "[15224.0, 15224.0]", + "[15347.0, 15347.0]", + "[15440.0, 15440.0]", + "[15549.0, 15549.0]", + "[16010.0, 16010.0]", + "[16535.0, 16535.0]", + "[16917.0, 16917.0]", + "[17013.0, 17013.0]", + "[17155.0, 17155.0]", + "[17762.0, 17762.0]", + "[17838.0, 17838.0]", + "[18208.0, 18208.0]", + "[18226.0, 18226.0]", + "[19339.0, 19339.0]", + "[19513.0, 19513.0]", + "[19951.0, 19951.0]", + "[19965.0, 19965.0]", + "[20119.0, 20119.0]", + "[20775.0, 20775.0]", + "[20778.0, 20778.0]", + "[20876.0, 20876.0]", + "[21423.0, 21423.0]", + "[21632.0, 21632.0]", + "[22018.0, 22018.0]", + "[22323.0, 22323.0]", + "[22354.0, 22354.0]", + "[22420.0, 22420.0]", + "[22431.0, 22431.0]", + "[22530.0, 22530.0]", + "[22993.0, 22993.0]", + "[23382.0, 23382.0]", + "[23406.0, 23406.0]", + "[23788.0, 23788.0]", + "[23817.0, 23817.0]", + "[23840.0, 23840.0]", + "[23842.0, 23842.0]", + "[24547.0, 24547.0]", + "[25178.0, 25178.0]", + "[25213.0, 25213.0]", + "[25741.0, 25741.0]", + "[25779.0, 25779.0]", + "[25984.0, 25984.0]", + "[26403.0, 26403.0]", + "[26470.0, 26470.0]", + "[26480.0, 26480.0]", + "[27615.0, 27615.0]", + "[27675.0, 27675.0]", + "[27724.0, 27724.0]", + "[27927.0, 27927.0]", + "[28126.0, 28126.0]", + "[28244.0, 28244.0]", + "[28600.0, 28600.0]", + "[29087.0, 29087.0]", + "[29301.0, 29301.0]", + "[29604.0, 29604.0]", + "[30138.0, 30138.0]", + "[31436.0, 31436.0]", + "[31452.0, 31452.0]", + "[31867.0, 31867.0]", + "[32273.0, 32273.0]", + "[32294.0, 32294.0]", + "[32676.0, 32676.0]", + "[32744.0, 32744.0]", + "[33479.0, 33479.0]", + "[33673.0, 33673.0]", + "[33937.0, 33937.0]", + "[34051.0, 34051.0]", + "[34642.0, 34642.0]", + "[35221.0, 35221.0]", + "[35871.0, 35871.0]", + "[36712.0, 36712.0]", + "[37259.0, 37259.0]", + "[37334.0, 37334.0]", + "[37981.0, 37981.0]", + "[38125.0, 38125.0]", + "[38419.0, 38419.0]", + "[38547.0, 38547.0]", + "[38982.0, 38982.0]", + "[39111.0, 39111.0]", + "[39888.0, 39888.0]", + "[40056.0, 40056.0]", + "[40147.0, 40147.0]", + "[40933.0, 40933.0]", + "[41204.0, 41204.0]", + "[41313.0, 41313.0]", + "[41478.0, 41478.0]", + "[41802.0, 41802.0]", + "[42450.0, 42450.0]", + "[42673.0, 42673.0]", + "[42701.0, 42701.0]", + "[42802.0, 42802.0]", + "[43347.0, 43347.0]", + "[44046.0, 44046.0]", + "[44650.0, 44650.0]", + "[45046.0, 45046.0]", + "[45308.0, 45308.0]", + "[45551.0, 45551.0]", + "[45663.0, 45663.0]", + "[45912.0, 45912.0]", + "[47410.0, 47410.0]", + "[47818.0, 47818.0]", + "[48700.0, 48700.0]", + "[48907.0, 48907.0]", + "[49104.0, 49104.0]", + "[49784.0, 49784.0]", + "[50218.0, 50218.0]", + "[50383.0, 50383.0]", + "[50570.0, 50570.0]", + "[50947.0, 50947.0]", + "[51683.0, 51683.0]", + "[51800.0, 51800.0]", + "[52059.0, 52059.0]", + "[53930.0, 53930.0]", + "[55068.0, 55068.0]", + "[55390.0, 55390.0]", + "[55395.0, 55395.0]", + "[55502.0, 55502.0]", + "[56037.0, 56037.0]", + "[56241.0, 56241.0]", + "[56524.0, 56524.0]", + "[56666.0, 56666.0]", + "[56708.0, 56708.0]", + "[56961.0, 56961.0]", + "[56962.0, 56962.0]", + "[58030.0, 58030.0]", + "[59577.0, 59577.0]", + "[59998.0, 59998.0]", + "[60085.0, 60085.0]", + "[60395.0, 60395.0]", + "[60882.0, 60882.0]", + "[60916.0, 60916.0]", + "[61539.0, 61539.0]", + "[61612.0, 61612.0]", + "[62114.0, 62114.0]", + "[62136.0, 62136.0]", + "[62318.0, 62318.0]", + "[62461.0, 62461.0]", + "[62827.0, 62827.0]", + "[63360.0, 63360.0]", + "[63695.0, 63695.0]", + "[63952.0, 63952.0]", + "[63995.0, 63995.0]", + "[64238.0, 64238.0]", + "[64336.0, 64336.0]", + "[65031.0, 65031.0]", + "[65583.0, 65583.0]", + "[65688.0, 65688.0]", + "[65696.0, 65696.0]", + "[65880.0, 65880.0]", + "[66943.0, 66943.0]", + "[67212.0, 67212.0]", + "[67219.0, 67219.0]", + "[67476.0, 67476.0]", + "[67654.0, 67654.0]", + "[67818.0, 67818.0]", + "[67936.0, 67936.0]", + "[67942.0, 67942.0]", + "[68332.0, 68332.0]", + "[68916.0, 68916.0]", + "[69474.0, 69474.0]", + "[69516.0, 69516.0]", + "[69727.0, 69727.0]", + "[69973.0, 69973.0]", + "[70024.0, 70024.0]", + "[70721.0, 70721.0]", + "[71479.0, 71479.0]", + "[71862.0, 71862.0]", + "[72293.0, 72293.0]", + "[73304.0, 73304.0]", + "[73323.0, 73323.0]", + "[73497.0, 73497.0]", + "[73505.0, 73505.0]", + "[73700.0, 73700.0]", + "[74041.0, 74041.0]", + "[74089.0, 74089.0]", + "[74367.0, 74367.0]", + "[75453.0, 75453.0]", + "[76167.0, 76167.0]", + "[76422.0, 76422.0]", + "[77032.0, 77032.0]", + "[77574.0, 77574.0]", + "[77842.0, 77842.0]", + "[78306.0, 78306.0]", + "[79272.0, 79272.0]", + "[79411.0, 79411.0]", + "[79451.0, 79451.0]", + "[79588.0, 79588.0]", + "[79991.0, 79991.0]", + "[80258.0, 80258.0]", + "[80842.0, 80842.0]", + "[80967.0, 80967.0]", + "[81204.0, 81204.0]", + "[81807.0, 81807.0]", + "[81923.0, 81923.0]", + "[82209.0, 82209.0]", + "[82573.0, 82573.0]", + "[82620.0, 82620.0]", + "[82636.0, 82636.0]", + "[82691.0, 82691.0]", + "[82837.0, 82837.0]", + "[83740.0, 83740.0]", + "[83851.0, 83851.0]", + "[84237.0, 84237.0]", + "[84301.0, 84301.0]", + "[84882.0, 84882.0]", + "[85334.0, 85334.0]", + "[85405.0, 85405.0]", + "[85606.0, 85606.0]", + "[86108.0, 86108.0]", + "[86311.0, 86311.0]", + "[87001.0, 87001.0]", + "[87243.0, 87243.0]", + "[87686.0, 87686.0]", + "[87903.0, 87903.0]", + "[88050.0, 88050.0]", + "[88064.0, 88064.0]", + "[88138.0, 88138.0]", + "[88307.0, 88307.0]", + "[88590.0, 88590.0]", + "[88964.0, 88964.0]", + "[89140.0, 89140.0]", + "[89167.0, 89167.0]", + "[89479.0, 89479.0]", + "[89847.0, 89847.0]", + "[90025.0, 90025.0]", + "[90056.0, 90056.0]", + "[90465.0, 90465.0]", + "[90466.0, 90466.0]", + "[90607.0, 90607.0]", + "[91120.0, 91120.0]", + "[91213.0, 91213.0]", + "[91271.0, 91271.0]", + "[91809.0, 91809.0]", + "[91830.0, 91830.0]", + "[92313.0, 92313.0]", + "[92892.0, 92892.0]", + "[92940.0, 92940.0]", + "[93536.0, 93536.0]", + "[93868.0, 93868.0]", + "[94144.0, 94144.0]", + "[94203.0, 94203.0]", + "[94896.0, 94896.0]", + "[95156.0, 95156.0]", + "[95169.0, 95169.0]", + "[95371.0, 95371.0]", + "[95955.0, 95955.0]", + "[96385.0, 96385.0]", + "[96391.0, 96391.0]", + "[96414.0, 96414.0]", + "[96626.0, 96626.0]", + "[97294.0, 97294.0]", + "[97504.0, 97504.0]", + "[98114.0, 98114.0]", + "[98426.0, 98426.0]", + "[98442.0, 98442.0]" + ], + "rd" : [ + "[7.0, inf]" + ], + "ard" : [ + "[MinKey, MaxKey]" + ] } - ], - "rejectedPlans" : [ - [ - { - "stage" : "SORT", - "sortPattern" : { - "ard" : 1 - }, - "memLimit" : 104857600, - "type" : "simple" - }, - { - "stage" : "FETCH", - "filter" : { - "_id" : { - "$in" : [ - 355, - 587, - 1310, - 1362, - 2483, - 3190, - 3318, - 3650, - 4543, - 4571, - 4578, - 4816, - 4913, - 5045, - 5459, - 5735, - 6596, - 6818, - 6870, - 7074, - 7090, - 7185, - 7361, - 7886, - 8042, - 8381, - 8551, - 9094, - 9114, - 9709, - 9909, - 10018, - 10624, - 10666, - 11022, - 11489, - 11646, - 11747, - 12240, - 12511, - 12623, - 12842, - 12961, - 14074, - 14370, - 15224, - 15347, - 15440, - 15549, - 16010, - 16535, - 16917, - 17013, - 17155, - 17762, - 17838, - 18208, - 18226, - 19339, - 19513, - 19951, - 19965, - 20119, - 20775, - 20778, - 20876, - 21423, - 21632, - 22018, - 22323, - 22354, - 22420, - 22431, - 22530, - 22993, - 23382, - 23406, - 23788, - 23817, - 23840, - 23842, - 24547, - 25178, - 25213, - 25741, - 25779, - 25984, - 26403, - 26470, - 26480, - 27615, - 27675, - 27724, - 27927, - 28126, - 28244, - 28600, - 29087, - 29301, - 29604, - 30138, - 31436, - 31452, - 31867, - 32273, - 32294, - 32676, - 32744, - 33479, - 33673, - 33937, - 34051, - 34642, - 35221, - 35871, - 36712, - 37259, - 37334, - 37981, - 38125, - 38419, - 38547, - 38982, - 39111, - 39888, - 40056, - 40147, - 40933, - 41204, - 41313, - 41478, - 41802, - 42450, - 42673, - 42701, - 42802, - 43347, - 44046, - 44650, - 45046, - 45308, - 45551, - 45663, - 45912, - 47410, - 47818, - 48700, - 48907, - 49104, - 49784, - 50218, - 50383, - 50570, - 50947, - 51683, - 51800, - 52059, - 53930, - 55068, - 55390, - 55395, - 55502, - 56037, - 56241, - 56524, - 56666, - 56708, - 56961, - 56962, - 58030, - 59577, - 59998, - 60085, - 60395, - 60882, - 60916, - 61539, - 61612, - 62114, - 62136, - 62318, - 62461, - 62827, - 63360, - 63695, - 63952, - 63995, - 64238, - 64336, - 65031, - 65583, - 65688, - 65696, - 65880, - 66943, - 67212, - 67219, - 67476, - 67654, - 67818, - 67936, - 67942, - 68332, - 68916, - 69474, - 69516, - 69727, - 69973, - 70024, - 70721, - 71479, - 71862, - 72293, - 73304, - 73323, - 73497, - 73505, - 73700, - 74041, - 74089, - 74367, - 75453, - 76167, - 76422, - 77032, - 77574, - 77842, - 78306, - 79272, - 79411, - 79451, - 79588, - 79991, - 80258, - 80842, - 80967, - 81204, - 81807, - 81923, - 82209, - 82573, - 82620, - 82636, - 82691, - 82837, - 83740, - 83851, - 84237, - 84301, - 84882, - 85334, - 85405, - 85606, - 86108, - 86311, - 87001, - 87243, - 87686, - 87903, - 88050, - 88064, - 88138, - 88307, - 88590, - 88964, - 89140, - 89167, - 89479, - 89847, - 90025, - 90056, - 90465, - 90466, - 90607, - 91120, - 91213, - 91271, - 91809, - 91830, - 92313, - 92892, - 92940, - 93536, - 93868, - 94144, - 94203, - 94896, - 95156, - 95169, - 95371, - 95955, - 96385, - 96391, - 96414, - 96626, - 97294, - 97504, - 98114, - 98426, - 98442 - ] - } - } - }, - { - "stage" : "IXSCAN", - "keyPattern" : { - "rd" : 1 - }, - "indexName" : "rd_1", - "isMultiKey" : false, - "multiKeyPaths" : { - "rd" : [ ] - }, - "isUnique" : false, - "isSparse" : false, - "isPartial" : false, - "direction" : "forward", - "indexBounds" : { - "rd" : [ - "[7.0, inf]" - ] - } - } - ], - [ - { - "stage" : "SORT", - "sortPattern" : { - "ard" : 1 - }, - "memLimit" : 104857600, - "type" : "simple" - }, - { - "stage" : "FETCH", - "filter" : { - "_id" : { - "$in" : [ - 355, - 587, - 1310, - 1362, - 2483, - 3190, - 3318, - 3650, - 4543, - 4571, - 4578, - 4816, - 4913, - 5045, - 5459, - 5735, - 6596, - 6818, - 6870, - 7074, - 7090, - 7185, - 7361, - 7886, - 8042, - 8381, - 8551, - 9094, - 9114, - 9709, - 9909, - 10018, - 10624, - 10666, - 11022, - 11489, - 11646, - 11747, - 12240, - 12511, - 12623, - 12842, - 12961, - 14074, - 14370, - 15224, - 15347, - 15440, - 15549, - 16010, - 16535, - 16917, - 17013, - 17155, - 17762, - 17838, - 18208, - 18226, - 19339, - 19513, - 19951, - 19965, - 20119, - 20775, - 20778, - 20876, - 21423, - 21632, - 22018, - 22323, - 22354, - 22420, - 22431, - 22530, - 22993, - 23382, - 23406, - 23788, - 23817, - 23840, - 23842, - 24547, - 25178, - 25213, - 25741, - 25779, - 25984, - 26403, - 26470, - 26480, - 27615, - 27675, - 27724, - 27927, - 28126, - 28244, - 28600, - 29087, - 29301, - 29604, - 30138, - 31436, - 31452, - 31867, - 32273, - 32294, - 32676, - 32744, - 33479, - 33673, - 33937, - 34051, - 34642, - 35221, - 35871, - 36712, - 37259, - 37334, - 37981, - 38125, - 38419, - 38547, - 38982, - 39111, - 39888, - 40056, - 40147, - 40933, - 41204, - 41313, - 41478, - 41802, - 42450, - 42673, - 42701, - 42802, - 43347, - 44046, - 44650, - 45046, - 45308, - 45551, - 45663, - 45912, - 47410, - 47818, - 48700, - 48907, - 49104, - 49784, - 50218, - 50383, - 50570, - 50947, - 51683, - 51800, - 52059, - 53930, - 55068, - 55390, - 55395, - 55502, - 56037, - 56241, - 56524, - 56666, - 56708, - 56961, - 56962, - 58030, - 59577, - 59998, - 60085, - 60395, - 60882, - 60916, - 61539, - 61612, - 62114, - 62136, - 62318, - 62461, - 62827, - 63360, - 63695, - 63952, - 63995, - 64238, - 64336, - 65031, - 65583, - 65688, - 65696, - 65880, - 66943, - 67212, - 67219, - 67476, - 67654, - 67818, - 67936, - 67942, - 68332, - 68916, - 69474, - 69516, - 69727, - 69973, - 70024, - 70721, - 71479, - 71862, - 72293, - 73304, - 73323, - 73497, - 73505, - 73700, - 74041, - 74089, - 74367, - 75453, - 76167, - 76422, - 77032, - 77574, - 77842, - 78306, - 79272, - 79411, - 79451, - 79588, - 79991, - 80258, - 80842, - 80967, - 81204, - 81807, - 81923, - 82209, - 82573, - 82620, - 82636, - 82691, - 82837, - 83740, - 83851, - 84237, - 84301, - 84882, - 85334, - 85405, - 85606, - 86108, - 86311, - 87001, - 87243, - 87686, - 87903, - 88050, - 88064, - 88138, - 88307, - 88590, - 88964, - 89140, - 89167, - 89479, - 89847, - 90025, - 90056, - 90465, - 90466, - 90607, - 91120, - 91213, - 91271, - 91809, - 91830, - 92313, - 92892, - 92940, - 93536, - 93868, - 94144, - 94203, - 94896, - 95156, - 95169, - 95371, - 95955, - 96385, - 96391, - 96414, - 96626, - 97294, - 97504, - 98114, - 98426, - 98442 - ] - } - } - }, - { - "stage" : "IXSCAN", - "keyPattern" : { - "rd" : 1, - "ard" : 1 - }, - "indexName" : "rd_1_ard_1", - "isMultiKey" : false, - "multiKeyPaths" : { - "rd" : [ ], - "ard" : [ ] - }, - "isUnique" : false, - "isSparse" : false, - "isPartial" : false, - "direction" : "forward", - "indexBounds" : { - "rd" : [ - "[7.0, inf]" - ], - "ard" : [ - "[MinKey, MaxKey]" - ] - } - } - ], - [ - { - "stage" : "SORT", - "sortPattern" : { - "ard" : 1 - }, - "memLimit" : 104857600, - "type" : "simple" - }, - { - "stage" : "FETCH", - "filter" : { - "rd" : { - "$gte" : 7 - } - } - }, - { - "stage" : "IXSCAN", - "keyPattern" : { - "_id" : 1 - }, - "indexName" : "_id_", - "isMultiKey" : false, - "isUnique" : true, - "isSparse" : false, - "isPartial" : false, - "direction" : "forward", - "indexBounds" : { - "_id" : [ - "[355.0, 355.0]", - "[587.0, 587.0]", - "[1310.0, 1310.0]", - "[1362.0, 1362.0]", - "[2483.0, 2483.0]", - "[3190.0, 3190.0]", - "[3318.0, 3318.0]", - "[3650.0, 3650.0]", - "[4543.0, 4543.0]", - "[4571.0, 4571.0]", - "[4578.0, 4578.0]", - "[4816.0, 4816.0]", - "[4913.0, 4913.0]", - "[5045.0, 5045.0]", - "[5459.0, 5459.0]", - "[5735.0, 5735.0]", - "[6596.0, 6596.0]", - "[6818.0, 6818.0]", - "[6870.0, 6870.0]", - "[7074.0, 7074.0]", - "[7090.0, 7090.0]", - "[7185.0, 7185.0]", - "[7361.0, 7361.0]", - "[7886.0, 7886.0]", - "[8042.0, 8042.0]", - "[8381.0, 8381.0]", - "[8551.0, 8551.0]", - "[9094.0, 9094.0]", - "[9114.0, 9114.0]", - "[9709.0, 9709.0]", - "[9909.0, 9909.0]", - "[10018.0, 10018.0]", - "[10624.0, 10624.0]", - "[10666.0, 10666.0]", - "[11022.0, 11022.0]", - "[11489.0, 11489.0]", - "[11646.0, 11646.0]", - "[11747.0, 11747.0]", - "[12240.0, 12240.0]", - "[12511.0, 12511.0]", - "[12623.0, 12623.0]", - "[12842.0, 12842.0]", - "[12961.0, 12961.0]", - "[14074.0, 14074.0]", - "[14370.0, 14370.0]", - "[15224.0, 15224.0]", - "[15347.0, 15347.0]", - "[15440.0, 15440.0]", - "[15549.0, 15549.0]", - "[16010.0, 16010.0]", - "[16535.0, 16535.0]", - "[16917.0, 16917.0]", - "[17013.0, 17013.0]", - "[17155.0, 17155.0]", - "[17762.0, 17762.0]", - "[17838.0, 17838.0]", - "[18208.0, 18208.0]", - "[18226.0, 18226.0]", - "[19339.0, 19339.0]", - "[19513.0, 19513.0]", - "[19951.0, 19951.0]", - "[19965.0, 19965.0]", - "[20119.0, 20119.0]", - "[20775.0, 20775.0]", - "[20778.0, 20778.0]", - "[20876.0, 20876.0]", - "[21423.0, 21423.0]", - "[21632.0, 21632.0]", - "[22018.0, 22018.0]", - "[22323.0, 22323.0]", - "[22354.0, 22354.0]", - "[22420.0, 22420.0]", - "[22431.0, 22431.0]", - "[22530.0, 22530.0]", - "[22993.0, 22993.0]", - "[23382.0, 23382.0]", - "[23406.0, 23406.0]", - "[23788.0, 23788.0]", - "[23817.0, 23817.0]", - "[23840.0, 23840.0]", - "[23842.0, 23842.0]", - "[24547.0, 24547.0]", - "[25178.0, 25178.0]", - "[25213.0, 25213.0]", - "[25741.0, 25741.0]", - "[25779.0, 25779.0]", - "[25984.0, 25984.0]", - "[26403.0, 26403.0]", - "[26470.0, 26470.0]", - "[26480.0, 26480.0]", - "[27615.0, 27615.0]", - "[27675.0, 27675.0]", - "[27724.0, 27724.0]", - "[27927.0, 27927.0]", - "[28126.0, 28126.0]", - "[28244.0, 28244.0]", - "[28600.0, 28600.0]", - "[29087.0, 29087.0]", - "[29301.0, 29301.0]", - "[29604.0, 29604.0]", - "[30138.0, 30138.0]", - "[31436.0, 31436.0]", - "[31452.0, 31452.0]", - "[31867.0, 31867.0]", - "[32273.0, 32273.0]", - "[32294.0, 32294.0]", - "[32676.0, 32676.0]", - "[32744.0, 32744.0]", - "[33479.0, 33479.0]", - "[33673.0, 33673.0]", - "[33937.0, 33937.0]", - "[34051.0, 34051.0]", - "[34642.0, 34642.0]", - "[35221.0, 35221.0]", - "[35871.0, 35871.0]", - "[36712.0, 36712.0]", - "[37259.0, 37259.0]", - "[37334.0, 37334.0]", - "[37981.0, 37981.0]", - "[38125.0, 38125.0]", - "[38419.0, 38419.0]", - "[38547.0, 38547.0]", - "[38982.0, 38982.0]", - "[39111.0, 39111.0]", - "[39888.0, 39888.0]", - "[40056.0, 40056.0]", - "[40147.0, 40147.0]", - "[40933.0, 40933.0]", - "[41204.0, 41204.0]", - "[41313.0, 41313.0]", - "[41478.0, 41478.0]", - "[41802.0, 41802.0]", - "[42450.0, 42450.0]", - "[42673.0, 42673.0]", - "[42701.0, 42701.0]", - "[42802.0, 42802.0]", - "[43347.0, 43347.0]", - "[44046.0, 44046.0]", - "[44650.0, 44650.0]", - "[45046.0, 45046.0]", - "[45308.0, 45308.0]", - "[45551.0, 45551.0]", - "[45663.0, 45663.0]", - "[45912.0, 45912.0]", - "[47410.0, 47410.0]", - "[47818.0, 47818.0]", - "[48700.0, 48700.0]", - "[48907.0, 48907.0]", - "[49104.0, 49104.0]", - "[49784.0, 49784.0]", - "[50218.0, 50218.0]", - "[50383.0, 50383.0]", - "[50570.0, 50570.0]", - "[50947.0, 50947.0]", - "[51683.0, 51683.0]", - "[51800.0, 51800.0]", - "[52059.0, 52059.0]", - "[53930.0, 53930.0]", - "[55068.0, 55068.0]", - "[55390.0, 55390.0]", - "[55395.0, 55395.0]", - "[55502.0, 55502.0]", - "[56037.0, 56037.0]", - "[56241.0, 56241.0]", - "[56524.0, 56524.0]", - "[56666.0, 56666.0]", - "[56708.0, 56708.0]", - "[56961.0, 56961.0]", - "[56962.0, 56962.0]", - "[58030.0, 58030.0]", - "[59577.0, 59577.0]", - "[59998.0, 59998.0]", - "[60085.0, 60085.0]", - "[60395.0, 60395.0]", - "[60882.0, 60882.0]", - "[60916.0, 60916.0]", - "[61539.0, 61539.0]", - "[61612.0, 61612.0]", - "[62114.0, 62114.0]", - "[62136.0, 62136.0]", - "[62318.0, 62318.0]", - "[62461.0, 62461.0]", - "[62827.0, 62827.0]", - "[63360.0, 63360.0]", - "[63695.0, 63695.0]", - "[63952.0, 63952.0]", - "[63995.0, 63995.0]", - "[64238.0, 64238.0]", - "[64336.0, 64336.0]", - "[65031.0, 65031.0]", - "[65583.0, 65583.0]", - "[65688.0, 65688.0]", - "[65696.0, 65696.0]", - "[65880.0, 65880.0]", - "[66943.0, 66943.0]", - "[67212.0, 67212.0]", - "[67219.0, 67219.0]", - "[67476.0, 67476.0]", - "[67654.0, 67654.0]", - "[67818.0, 67818.0]", - "[67936.0, 67936.0]", - "[67942.0, 67942.0]", - "[68332.0, 68332.0]", - "[68916.0, 68916.0]", - "[69474.0, 69474.0]", - "[69516.0, 69516.0]", - "[69727.0, 69727.0]", - "[69973.0, 69973.0]", - "[70024.0, 70024.0]", - "[70721.0, 70721.0]", - "[71479.0, 71479.0]", - "[71862.0, 71862.0]", - "[72293.0, 72293.0]", - "[73304.0, 73304.0]", - "[73323.0, 73323.0]", - "[73497.0, 73497.0]", - "[73505.0, 73505.0]", - "[73700.0, 73700.0]", - "[74041.0, 74041.0]", - "[74089.0, 74089.0]", - "[74367.0, 74367.0]", - "[75453.0, 75453.0]", - "[76167.0, 76167.0]", - "[76422.0, 76422.0]", - "[77032.0, 77032.0]", - "[77574.0, 77574.0]", - "[77842.0, 77842.0]", - "[78306.0, 78306.0]", - "[79272.0, 79272.0]", - "[79411.0, 79411.0]", - "[79451.0, 79451.0]", - "[79588.0, 79588.0]", - "[79991.0, 79991.0]", - "[80258.0, 80258.0]", - "[80842.0, 80842.0]", - "[80967.0, 80967.0]", - "[81204.0, 81204.0]", - "[81807.0, 81807.0]", - "[81923.0, 81923.0]", - "[82209.0, 82209.0]", - "[82573.0, 82573.0]", - "[82620.0, 82620.0]", - "[82636.0, 82636.0]", - "[82691.0, 82691.0]", - "[82837.0, 82837.0]", - "[83740.0, 83740.0]", - "[83851.0, 83851.0]", - "[84237.0, 84237.0]", - "[84301.0, 84301.0]", - "[84882.0, 84882.0]", - "[85334.0, 85334.0]", - "[85405.0, 85405.0]", - "[85606.0, 85606.0]", - "[86108.0, 86108.0]", - "[86311.0, 86311.0]", - "[87001.0, 87001.0]", - "[87243.0, 87243.0]", - "[87686.0, 87686.0]", - "[87903.0, 87903.0]", - "[88050.0, 88050.0]", - "[88064.0, 88064.0]", - "[88138.0, 88138.0]", - "[88307.0, 88307.0]", - "[88590.0, 88590.0]", - "[88964.0, 88964.0]", - "[89140.0, 89140.0]", - "[89167.0, 89167.0]", - "[89479.0, 89479.0]", - "[89847.0, 89847.0]", - "[90025.0, 90025.0]", - "[90056.0, 90056.0]", - "[90465.0, 90465.0]", - "[90466.0, 90466.0]", - "[90607.0, 90607.0]", - "[91120.0, 91120.0]", - "[91213.0, 91213.0]", - "[91271.0, 91271.0]", - "[91809.0, 91809.0]", - "[91830.0, 91830.0]", - "[92313.0, 92313.0]", - "[92892.0, 92892.0]", - "[92940.0, 92940.0]", - "[93536.0, 93536.0]", - "[93868.0, 93868.0]", - "[94144.0, 94144.0]", - "[94203.0, 94203.0]", - "[94896.0, 94896.0]", - "[95156.0, 95156.0]", - "[95169.0, 95169.0]", - "[95371.0, 95371.0]", - "[95955.0, 95955.0]", - "[96385.0, 96385.0]", - "[96391.0, 96391.0]", - "[96414.0, 96414.0]", - "[96626.0, 96626.0]", - "[97294.0, 97294.0]", - "[97504.0, 97504.0]", - "[98114.0, 98114.0]", - "[98426.0, 98426.0]", - "[98442.0, 98442.0]" - ] - } - } - ], - [ - { - "stage" : "FETCH", - "filter" : { - "$and" : [ - { - "rd" : { - "$gte" : 7 - } - }, - { - "_id" : { - "$in" : [ - 355, - 587, - 1310, - 1362, - 2483, - 3190, - 3318, - 3650, - 4543, - 4571, - 4578, - 4816, - 4913, - 5045, - 5459, - 5735, - 6596, - 6818, - 6870, - 7074, - 7090, - 7185, - 7361, - 7886, - 8042, - 8381, - 8551, - 9094, - 9114, - 9709, - 9909, - 10018, - 10624, - 10666, - 11022, - 11489, - 11646, - 11747, - 12240, - 12511, - 12623, - 12842, - 12961, - 14074, - 14370, - 15224, - 15347, - 15440, - 15549, - 16010, - 16535, - 16917, - 17013, - 17155, - 17762, - 17838, - 18208, - 18226, - 19339, - 19513, - 19951, - 19965, - 20119, - 20775, - 20778, - 20876, - 21423, - 21632, - 22018, - 22323, - 22354, - 22420, - 22431, - 22530, - 22993, - 23382, - 23406, - 23788, - 23817, - 23840, - 23842, - 24547, - 25178, - 25213, - 25741, - 25779, - 25984, - 26403, - 26470, - 26480, - 27615, - 27675, - 27724, - 27927, - 28126, - 28244, - 28600, - 29087, - 29301, - 29604, - 30138, - 31436, - 31452, - 31867, - 32273, - 32294, - 32676, - 32744, - 33479, - 33673, - 33937, - 34051, - 34642, - 35221, - 35871, - 36712, - 37259, - 37334, - 37981, - 38125, - 38419, - 38547, - 38982, - 39111, - 39888, - 40056, - 40147, - 40933, - 41204, - 41313, - 41478, - 41802, - 42450, - 42673, - 42701, - 42802, - 43347, - 44046, - 44650, - 45046, - 45308, - 45551, - 45663, - 45912, - 47410, - 47818, - 48700, - 48907, - 49104, - 49784, - 50218, - 50383, - 50570, - 50947, - 51683, - 51800, - 52059, - 53930, - 55068, - 55390, - 55395, - 55502, - 56037, - 56241, - 56524, - 56666, - 56708, - 56961, - 56962, - 58030, - 59577, - 59998, - 60085, - 60395, - 60882, - 60916, - 61539, - 61612, - 62114, - 62136, - 62318, - 62461, - 62827, - 63360, - 63695, - 63952, - 63995, - 64238, - 64336, - 65031, - 65583, - 65688, - 65696, - 65880, - 66943, - 67212, - 67219, - 67476, - 67654, - 67818, - 67936, - 67942, - 68332, - 68916, - 69474, - 69516, - 69727, - 69973, - 70024, - 70721, - 71479, - 71862, - 72293, - 73304, - 73323, - 73497, - 73505, - 73700, - 74041, - 74089, - 74367, - 75453, - 76167, - 76422, - 77032, - 77574, - 77842, - 78306, - 79272, - 79411, - 79451, - 79588, - 79991, - 80258, - 80842, - 80967, - 81204, - 81807, - 81923, - 82209, - 82573, - 82620, - 82636, - 82691, - 82837, - 83740, - 83851, - 84237, - 84301, - 84882, - 85334, - 85405, - 85606, - 86108, - 86311, - 87001, - 87243, - 87686, - 87903, - 88050, - 88064, - 88138, - 88307, - 88590, - 88964, - 89140, - 89167, - 89479, - 89847, - 90025, - 90056, - 90465, - 90466, - 90607, - 91120, - 91213, - 91271, - 91809, - 91830, - 92313, - 92892, - 92940, - 93536, - 93868, - 94144, - 94203, - 94896, - 95156, - 95169, - 95371, - 95955, - 96385, - 96391, - 96414, - 96626, - 97294, - 97504, - 98114, - 98426, - 98442 - ] - } - } - ] - } - }, - { - "stage" : "IXSCAN", - "keyPattern" : { - "ard" : 1 - }, - "indexName" : "ard_1", - "isMultiKey" : false, - "multiKeyPaths" : { - "ard" : [ ] - }, - "isUnique" : false, - "isSparse" : false, - "isPartial" : false, - "direction" : "forward", - "indexBounds" : { - "ard" : [ - "[MinKey, MaxKey]" - ] - } - } - ] - ], - "queryShapeHash" : "6A981A874A98EC5B27AFA0941BFEB5A830D330C1606A2894BE7D27F98480C47C" -} + } +] ``` ### Output `[ { "_id" : 2483, "rd" : 79880, "ard" : 164 }, { "_id" : 7074, "rd" : 60758, "ard" : 189 }, { "_id" : 3190, "rd" : 66330, "ard" : 455 }, { "_id" : 37259, "rd" : 83068, "ard" : 699 }, { "_id" : 37981, "rd" : 2492, "ard" : 1117 }, { "_id" : 69973, "rd" : 22800, "ard" : 1542 }, { "_id" : 12842, "rd" : 15026, "ard" : 2336 }, { "_id" : 5735, "rd" : 74629, "ard" : 3175 }, { "_id" : 19339, "rd" : 36896, "ard" : 3419 }, { "_id" : 52059, "rd" : 57665, "ard" : 3606 }, { "_id" : 67212, "rd" : 73854, "ard" : 3718 }, { "_id" : 62114, "rd" : 40952, "ard" : 4179 }, { "_id" : 88050, "rd" : 35688, "ard" : 4397 }, { "_id" : 58030, "rd" : 48835, "ard" : 4402 }, { "_id" : 23840, "rd" : 44541, "ard" : 4854 }, { "_id" : 23842, "rd" : 90788, "ard" : 4950 }, { "_id" : 89479, "rd" : 27851, "ard" : 5155 }, { "_id" : 59998, "rd" : 18773, "ard" : 6034 }, { "_id" : 97504, "rd" : 87565, "ard" : 6683 }, { "_id" : 56524, "rd" : 69380, "ard" : 7514 }, { "_id" : 77842, "rd" : 28994, "ard" : 7675 }, { "_id" : 10018, "rd" : 87834, "ard" : 7693 }, { "_id" : 81923, "rd" : 69249, "ard" : 7951 }, { "_id" : 25213, "rd" : 14396, "ard" : 8024 }, { "_id" : 22993, "rd" : 28495, "ard" : 8028 }, { "_id" : 41204, "rd" : 7641, "ard" : 8504 }, { "_id" : 60916, "rd" : 64574, "ard" : 9109 }, { "_id" : 79411, "rd" : 7649, "ard" : 9186 }, { "_id" : 42673, "rd" : 32397, "ard" : 9676 }, { "_id" : 79272, "rd" : 82242, "ard" : 9774 }, { "_id" : 15347, "rd" : 24440, "ard" : 9815 }, { "_id" : 56666, "rd" : 58211, "ard" : 10034 }, { "_id" : 68916, "rd" : 22474, "ard" : 10688 }, { "_id" : 79588, "rd" : 14298, "ard" : 11314 }, { "_id" : 17762, "rd" : 92209, "ard" : 12360 }, { "_id" : 65696, "rd" : 97113, "ard" : 12374 }, { "_id" : 65031, "rd" : 89135, "ard" : 12807 }, { "_id" : 1310, "rd" : 44035, "ard" : 12900 }, { "_id" : 87001, "rd" : 81206, "ard" : 13119 }, { "_id" : 80842, "rd" : 35626, "ard" : 13270 }, { "_id" : 96385, "rd" : 41544, "ard" : 13319 }, { "_id" : 90025, "rd" : 37941, "ard" : 13325 }, { "_id" : 38125, "rd" : 67383, "ard" : 13623 }, { "_id" : 73497, "rd" : 76971, "ard" : 13649 }, { "_id" : 83851, "rd" : 16006, "ard" : 14545 }, { "_id" : 95955, "rd" : 27225, "ard" : 14630 }, { "_id" : 32744, "rd" : 8269, "ard" : 15044 }, { "_id" : 55502, "rd" : 37585, "ard" : 15550 }, { "_id" : 69516, "rd" : 35328, "ard" : 16385 }, { "_id" : 88307, "rd" : 53335, "ard" : 16445 }, { "_id" : 75453, "rd" : 89882, "ard" : 17061 }, { "_id" : 62318, "rd" : 73463, "ard" : 17441 }, { "_id" : 84301, "rd" : 75436, "ard" : 17870 }, { "_id" : 28126, "rd" : 64004, "ard" : 18488 }, { "_id" : 83740, "rd" : 28115, "ard" : 18713 }, { "_id" : 63995, "rd" : 33579, "ard" : 18937 }, { "_id" : 50947, "rd" : 35221, "ard" : 19680 }, { "_id" : 18226, "rd" : 49450, "ard" : 19728 }, { "_id" : 64336, "rd" : 85455, "ard" : 19784 }, { "_id" : 90607, "rd" : 75534, "ard" : 19818 }, { "_id" : 55068, "rd" : 33597, "ard" : 20863 }, { "_id" : 67476, "rd" : 13986, "ard" : 20922 }, { "_id" : 29301, "rd" : 26088, "ard" : 20942 }, { "_id" : 23788, "rd" : 13594, "ard" : 21101 }, { "_id" : 76422, "rd" : 96124, "ard" : 21766 }, { "_id" : 92940, "rd" : 32562, "ard" : 21949 }, { "_id" : 19513, "rd" : 62845, "ard" : 22835 }, { "_id" : 51800, "rd" : 98110, "ard" : 22944 }, { "_id" : 81204, "rd" : 52468, "ard" : 22979 }, { "_id" : 98442, "rd" : 58034, "ard" : 24418 }, { "_id" : 89140, "rd" : 53817, "ard" : 24446 }, { "_id" : 87686, "rd" : 21936, "ard" : 24468 }, { "_id" : 25779, "rd" : 9131, "ard" : 24570 }, { "_id" : 40147, "rd" : 49252, "ard" : 24704 }, { "_id" : 20876, "rd" : 79619, "ard" : 24934 }, { "_id" : 91830, "rd" : 77419, "ard" : 25562 }, { "_id" : 19965, "rd" : 28974, "ard" : 25772 }, { "_id" : 79451, "rd" : 85778, "ard" : 25848 }, { "_id" : 82837, "rd" : 83948, "ard" : 26314 }, { "_id" : 82691, "rd" : 89430, "ard" : 26490 }, { "_id" : 61539, "rd" : 68877, "ard" : 26767 }, { "_id" : 88138, "rd" : 61532, "ard" : 27729 }, { "_id" : 41478, "rd" : 4311, "ard" : 27801 }, { "_id" : 74041, "rd" : 93479, "ard" : 27997 }, { "_id" : 31452, "rd" : 64533, "ard" : 28420 }, { "_id" : 91809, "rd" : 37680, "ard" : 28485 }, { "_id" : 89847, "rd" : 16204, "ard" : 28772 }, { "_id" : 3650, "rd" : 48842, "ard" : 28998 }, { "_id" : 86311, "rd" : 71544, "ard" : 29418 }, { "_id" : 87903, "rd" : 9433, "ard" : 30112 }, { "_id" : 6870, "rd" : 46336, "ard" : 30132 }, { "_id" : 60085, "rd" : 49503, "ard" : 30272 }, { "_id" : 94203, "rd" : 76943, "ard" : 30425 }, { "_id" : 96391, "rd" : 69751, "ard" : 30510 }, { "_id" : 62461, "rd" : 55561, "ard" : 30749 }, { "_id" : 12240, "rd" : 47531, "ard" : 30884 }, { "_id" : 79991, "rd" : 66192, "ard" : 30987 }, { "_id" : 8042, "rd" : 56954, "ard" : 31302 }, { "_id" : 39111, "rd" : 56867, "ard" : 31502 }, { "_id" : 6818, "rd" : 84473, "ard" : 31516 }, { "_id" : 82620, "rd" : 22941, "ard" : 31725 }, { "_id" : 9094, "rd" : 61462, "ard" : 31942 }, { "_id" : 67219, "rd" : 75578, "ard" : 33023 }, { "_id" : 92313, "rd" : 42141, "ard" : 33880 }, { "_id" : 28600, "rd" : 95439, "ard" : 33886 }, { "_id" : 74089, "rd" : 88799, "ard" : 34110 }, { "_id" : 50570, "rd" : 8716, "ard" : 34725 }, { "_id" : 32273, "rd" : 51463, "ard" : 35459 }, { "_id" : 97294, "rd" : 94981, "ard" : 35515 }, { "_id" : 24547, "rd" : 79825, "ard" : 35608 }, { "_id" : 90466, "rd" : 53162, "ard" : 35743 }, { "_id" : 47818, "rd" : 54505, "ard" : 36086 }, { "_id" : 87243, "rd" : 62996, "ard" : 36648 }, { "_id" : 26470, "rd" : 5710, "ard" : 36874 }, { "_id" : 48907, "rd" : 24356, "ard" : 37385 }, { "_id" : 56708, "rd" : 42830, "ard" : 37994 }, { "_id" : 20775, "rd" : 85644, "ard" : 38644 }, { "_id" : 23817, "rd" : 30565, "ard" : 39127 }, { "_id" : 36712, "rd" : 98810, "ard" : 40169 }, { "_id" : 31436, "rd" : 49412, "ard" : 40312 }, { "_id" : 60882, "rd" : 72374, "ard" : 40342 }, { "_id" : 27927, "rd" : 5012, "ard" : 40736 }, { "_id" : 92892, "rd" : 99007, "ard" : 40778 }, { "_id" : 26403, "rd" : 64553, "ard" : 41009 }, { "_id" : 11022, "rd" : 71245, "ard" : 41177 }, { "_id" : 82573, "rd" : 86794, "ard" : 41386 }, { "_id" : 49104, "rd" : 57153, "ard" : 41608 }, { "_id" : 4578, "rd" : 33664, "ard" : 41909 }, { "_id" : 15440, "rd" : 26330, "ard" : 42164 }, { "_id" : 3318, "rd" : 4125, "ard" : 42320 }, { "_id" : 63952, "rd" : 55814, "ard" : 42800 }, { "_id" : 587, "rd" : 79323, "ard" : 43207 }, { "_id" : 63695, "rd" : 44281, "ard" : 43209 }, { "_id" : 40933, "rd" : 51521, "ard" : 43275 }, { "_id" : 23406, "rd" : 72853, "ard" : 43561 }, { "_id" : 39888, "rd" : 28286, "ard" : 43705 }, { "_id" : 9709, "rd" : 82588, "ard" : 43975 }, { "_id" : 96414, "rd" : 4625, "ard" : 44356 }, { "_id" : 41802, "rd" : 96977, "ard" : 44438 }, { "_id" : 91213, "rd" : 28101, "ard" : 44938 }, { "_id" : 61612, "rd" : 17322, "ard" : 45151 }, { "_id" : 94896, "rd" : 8964, "ard" : 45838 }, { "_id" : 84237, "rd" : 2197, "ard" : 46076 }, { "_id" : 23382, "rd" : 92794, "ard" : 46150 }, { "_id" : 85606, "rd" : 47352, "ard" : 46179 }, { "_id" : 27615, "rd" : 85645, "ard" : 46619 }, { "_id" : 89167, "rd" : 52122, "ard" : 47621 }, { "_id" : 22530, "rd" : 32620, "ard" : 47815 }, { "_id" : 16535, "rd" : 10402, "ard" : 49460 }, { "_id" : 16917, "rd" : 84046, "ard" : 49798 }, { "_id" : 53930, "rd" : 94284, "ard" : 50041 }, { "_id" : 4571, "rd" : 64259, "ard" : 50785 }, { "_id" : 31867, "rd" : 51998, "ard" : 50828 }, { "_id" : 68332, "rd" : 70855, "ard" : 51269 }, { "_id" : 73323, "rd" : 56873, "ard" : 51303 }, { "_id" : 4816, "rd" : 63223, "ard" : 51654 }, { "_id" : 47410, "rd" : 2454, "ard" : 51988 }, { "_id" : 69727, "rd" : 94729, "ard" : 52598 }, { "_id" : 67936, "rd" : 25992, "ard" : 53283 }, { "_id" : 50383, "rd" : 1971, "ard" : 53634 }, { "_id" : 55395, "rd" : 26735, "ard" : 53678 }, { "_id" : 35871, "rd" : 29558, "ard" : 53778 }, { "_id" : 28244, "rd" : 20437, "ard" : 53880 }, { "_id" : 33673, "rd" : 69698, "ard" : 54051 }, { "_id" : 9909, "rd" : 68049, "ard" : 54094 }, { "_id" : 7090, "rd" : 45301, "ard" : 54222 }, { "_id" : 67818, "rd" : 9213, "ard" : 54256 }, { "_id" : 20778, "rd" : 45965, "ard" : 54482 }, { "_id" : 70024, "rd" : 4415, "ard" : 54517 }, { "_id" : 66943, "rd" : 47593, "ard" : 54575 }, { "_id" : 29087, "rd" : 81741, "ard" : 54772 }, { "_id" : 65583, "rd" : 84137, "ard" : 54927 }, { "_id" : 20119, "rd" : 94999, "ard" : 55072 }, { "_id" : 17155, "rd" : 50945, "ard" : 55210 }, { "_id" : 93868, "rd" : 6615, "ard" : 55627 }, { "_id" : 41313, "rd" : 87374, "ard" : 56026 }, { "_id" : 65688, "rd" : 69807, "ard" : 56566 }, { "_id" : 34051, "rd" : 92390, "ard" : 56624 }, { "_id" : 6596, "rd" : 26317, "ard" : 56719 }, { "_id" : 33479, "rd" : 34653, "ard" : 56797 }, { "_id" : 29604, "rd" : 99116, "ard" : 56925 }, { "_id" : 45551, "rd" : 37548, "ard" : 56952 }, { "_id" : 80967, "rd" : 76860, "ard" : 57032 }, { "_id" : 17013, "rd" : 15674, "ard" : 57406 }, { "_id" : 95156, "rd" : 19420, "ard" : 57914 }, { "_id" : 18208, "rd" : 87912, "ard" : 58092 }, { "_id" : 25984, "rd" : 26124, "ard" : 58507 }, { "_id" : 32676, "rd" : 296, "ard" : 59586 }, { "_id" : 81807, "rd" : 63139, "ard" : 60187 }, { "_id" : 51683, "rd" : 91885, "ard" : 60552 }, { "_id" : 85334, "rd" : 14701, "ard" : 60834 }, { "_id" : 17838, "rd" : 72966, "ard" : 61193 }, { "_id" : 37334, "rd" : 24595, "ard" : 62074 }, { "_id" : 65880, "rd" : 59601, "ard" : 62842 }, { "_id" : 95169, "rd" : 49480, "ard" : 63021 }, { "_id" : 11646, "rd" : 35932, "ard" : 63994 }, { "_id" : 56241, "rd" : 16205, "ard" : 65080 }, { "_id" : 22354, "rd" : 73141, "ard" : 65247 }, { "_id" : 70721, "rd" : 12112, "ard" : 65427 }, { "_id" : 34642, "rd" : 8926, "ard" : 65445 }, { "_id" : 4913, "rd" : 53943, "ard" : 65869 }, { "_id" : 69474, "rd" : 69702, "ard" : 65982 }, { "_id" : 44650, "rd" : 52841, "ard" : 66617 }, { "_id" : 11747, "rd" : 47398, "ard" : 66661 }, { "_id" : 48700, "rd" : 56627, "ard" : 66757 }, { "_id" : 33937, "rd" : 13242, "ard" : 66839 }, { "_id" : 88064, "rd" : 84593, "ard" : 66987 }, { "_id" : 15549, "rd" : 67042, "ard" : 67384 }, { "_id" : 98114, "rd" : 45813, "ard" : 67513 }, { "_id" : 7886, "rd" : 82389, "ard" : 67880 }, { "_id" : 94144, "rd" : 1193, "ard" : 67909 }, { "_id" : 71479, "rd" : 17788, "ard" : 68305 }, { "_id" : 49784, "rd" : 52332, "ard" : 68503 }, { "_id" : 60395, "rd" : 41848, "ard" : 68564 }, { "_id" : 88964, "rd" : 49238, "ard" : 68827 }, { "_id" : 5045, "rd" : 60250, "ard" : 69514 }, { "_id" : 74367, "rd" : 38854, "ard" : 69720 }, { "_id" : 96626, "rd" : 38517, "ard" : 70088 }, { "_id" : 80258, "rd" : 73172, "ard" : 70151 }, { "_id" : 45912, "rd" : 98813, "ard" : 70392 }, { "_id" : 43347, "rd" : 74239, "ard" : 70508 }, { "_id" : 38982, "rd" : 78107, "ard" : 70940 }, { "_id" : 15224, "rd" : 47562, "ard" : 71525 }, { "_id" : 56961, "rd" : 51666, "ard" : 72061 }, { "_id" : 45308, "rd" : 97776, "ard" : 72082 }, { "_id" : 56962, "rd" : 53513, "ard" : 72100 }, { "_id" : 22431, "rd" : 42281, "ard" : 72494 }, { "_id" : 55390, "rd" : 72815, "ard" : 72727 }, { "_id" : 45046, "rd" : 3972, "ard" : 73127 }, { "_id" : 63360, "rd" : 76612, "ard" : 73304 }, { "_id" : 62136, "rd" : 6522, "ard" : 73424 }, { "_id" : 26480, "rd" : 34128, "ard" : 73596 }, { "_id" : 21423, "rd" : 51576, "ard" : 74094 }, { "_id" : 71862, "rd" : 11788, "ard" : 74709 }, { "_id" : 73304, "rd" : 58556, "ard" : 75607 }, { "_id" : 72293, "rd" : 1402, "ard" : 75753 }, { "_id" : 59577, "rd" : 19052, "ard" : 76065 }, { "_id" : 22420, "rd" : 15745, "ard" : 77225 }, { "_id" : 12511, "rd" : 61562, "ard" : 77259 }, { "_id" : 1362, "rd" : 32132, "ard" : 77493 }, { "_id" : 82209, "rd" : 65068, "ard" : 77870 }, { "_id" : 14370, "rd" : 76358, "ard" : 78098 }, { "_id" : 77032, "rd" : 52610, "ard" : 78397 }, { "_id" : 7361, "rd" : 66877, "ard" : 79707 }, { "_id" : 42802, "rd" : 75902, "ard" : 79729 }, { "_id" : 11489, "rd" : 78820, "ard" : 79795 }, { "_id" : 4543, "rd" : 97852, "ard" : 80274 }, { "_id" : 38419, "rd" : 36713, "ard" : 80387 }, { "_id" : 42450, "rd" : 72171, "ard" : 80417 }, { "_id" : 12961, "rd" : 78826, "ard" : 80426 }, { "_id" : 355, "rd" : 45029, "ard" : 80467 }, { "_id" : 91120, "rd" : 88083, "ard" : 80743 }, { "_id" : 25178, "rd" : 66581, "ard" : 81016 }, { "_id" : 98426, "rd" : 55877, "ard" : 81038 }, { "_id" : 44046, "rd" : 82102, "ard" : 81215 }, { "_id" : 5459, "rd" : 37966, "ard" : 82267 }, { "_id" : 67942, "rd" : 52941, "ard" : 82278 }, { "_id" : 7185, "rd" : 84134, "ard" : 83106 }, { "_id" : 27724, "rd" : 23374, "ard" : 83821 }, { "_id" : 82636, "rd" : 65993, "ard" : 84040 }, { "_id" : 85405, "rd" : 42279, "ard" : 84720 }, { "_id" : 64238, "rd" : 35667, "ard" : 85120 }, { "_id" : 40056, "rd" : 18916, "ard" : 85452 }, { "_id" : 35221, "rd" : 5757, "ard" : 85556 }, { "_id" : 21632, "rd" : 96333, "ard" : 86219 }, { "_id" : 90056, "rd" : 35967, "ard" : 86619 }, { "_id" : 93536, "rd" : 89747, "ard" : 86851 }, { "_id" : 78306, "rd" : 19812, "ard" : 87113 }, { "_id" : 16010, "rd" : 61326, "ard" : 87272 }, { "_id" : 73505, "rd" : 60553, "ard" : 88112 }, { "_id" : 38547, "rd" : 90136, "ard" : 88239 }, { "_id" : 90465, "rd" : 75549, "ard" : 88822 }, { "_id" : 9114, "rd" : 74372, "ard" : 89065 }, { "_id" : 10624, "rd" : 66568, "ard" : 89081 }, { "_id" : 32294, "rd" : 70984, "ard" : 89087 }, { "_id" : 50218, "rd" : 62677, "ard" : 89743 }, { "_id" : 91271, "rd" : 19674, "ard" : 89912 }, { "_id" : 14074, "rd" : 97926, "ard" : 89967 }, { "_id" : 56037, "rd" : 76417, "ard" : 91733 }, { "_id" : 45663, "rd" : 36491, "ard" : 92244 }, { "_id" : 8381, "rd" : 49179, "ard" : 92248 }, { "_id" : 19951, "rd" : 17607, "ard" : 92320 }, { "_id" : 12623, "rd" : 11713, "ard" : 92585 }, { "_id" : 73700, "rd" : 31184, "ard" : 92617 }, { "_id" : 62827, "rd" : 89486, "ard" : 93648 }, { "_id" : 77574, "rd" : 44597, "ard" : 93749 }, { "_id" : 84882, "rd" : 67477, "ard" : 93788 }, { "_id" : 10666, "rd" : 24675, "ard" : 94385 }, { "_id" : 8551, "rd" : 64957, "ard" : 95132 }, { "_id" : 22018, "rd" : 35541, "ard" : 95165 }, { "_id" : 27675, "rd" : 66252, "ard" : 95172 }, { "_id" : 25741, "rd" : 54834, "ard" : 95374 }, { "_id" : 42701, "rd" : 12239, "ard" : 95700 }, { "_id" : 30138, "rd" : 74039, "ard" : 95927 }, { "_id" : 88590, "rd" : 23128, "ard" : 96081 }, { "_id" : 67654, "rd" : 69303, "ard" : 97544 }, { "_id" : 95371, "rd" : 31470, "ard" : 97582 }, { "_id" : 22323, "rd" : 62002, "ard" : 98960 }, { "_id" : 86108, "rd" : 86272, "ard" : 99028 }, { "_id" : 76167, "rd" : 73626, "ard" : 99232 } ]` diff --git a/jstests/query_golden/expected_output/sbeDisabled/base_coll_reorder.md b/jstests/query_golden/expected_output/sbeDisabled/base_coll_reorder.md index 0af6dfa2e9c..05c04270cce 100644 --- a/jstests/query_golden/expected_output/sbeDisabled/base_coll_reorder.md +++ b/jstests/query_golden/expected_output/sbeDisabled/base_coll_reorder.md @@ -55,6 +55,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -164,6 +165,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -268,6 +270,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -405,6 +408,7 @@ Execution Engine: classic } }, "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -613,6 +617,7 @@ Execution Engine: classic } }, "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } diff --git a/jstests/query_golden/expected_output/sbeDisabled/basic_joins.md b/jstests/query_golden/expected_output/sbeDisabled/basic_joins.md index 7c25e224d2d..2cbde4ae49f 100644 --- a/jstests/query_golden/expected_output/sbeDisabled/basic_joins.md +++ b/jstests/query_golden/expected_output/sbeDisabled/basic_joins.md @@ -48,6 +48,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -130,6 +131,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -137,6 +139,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -152,6 +155,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -216,6 +220,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -225,6 +230,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -232,6 +238,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -306,6 +313,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -313,6 +321,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -328,6 +337,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -394,6 +404,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -401,6 +412,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -416,6 +428,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -482,6 +495,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -489,6 +503,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -504,6 +519,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -570,6 +586,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -577,6 +594,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -592,6 +610,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -658,6 +677,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -665,6 +685,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -680,6 +701,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -694,6 +716,105 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "2312073BEBB7A5E1754E2D03D9CB40B75C126DBF60867D4639E7E281C9E3DFAC", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 6, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 2. Basic example with two joins and suffix ### No join opt ### Pipeline @@ -742,6 +863,7 @@ Execution Engine: classic "winningPlan" : { "inputStage" : { "direction" : "forward", + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "isCached" : false, @@ -852,6 +974,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -866,6 +989,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -881,6 +1005,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -967,6 +1092,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -977,6 +1103,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -991,6 +1118,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1088,6 +1216,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1102,6 +1231,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1117,6 +1247,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1205,6 +1336,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1213,6 +1345,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1235,6 +1368,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1323,6 +1457,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1331,6 +1466,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1353,6 +1489,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1441,6 +1578,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1449,6 +1587,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1471,6 +1610,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1559,6 +1699,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1567,6 +1708,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1589,6 +1731,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1624,6 +1767,135 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$y.b" + } +] +``` +### Results +```json +{ "_id" : "bar", "count" : 6 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "8E0DF14D3DA69D8B1CF0361E869369F9C5E5F2F2A5D81998E6800BDA4F997B57", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$y.b", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 3. Example with two joins, suffix, and sub-pipeline with un-correlated $match ### No join opt ### Pipeline @@ -1691,6 +1963,7 @@ Execution Engine: classic "winningPlan" : { "inputStage" : { "direction" : "forward", + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "isCached" : false, @@ -1844,6 +2117,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1860,6 +2134,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1877,6 +2152,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1984,6 +2260,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1994,6 +2271,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2010,6 +2288,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2126,6 +2405,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2142,6 +2422,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2159,6 +2440,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2268,6 +2550,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -2276,6 +2559,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2300,6 +2584,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2409,6 +2694,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -2417,6 +2703,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2441,6 +2728,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2550,6 +2838,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -2558,6 +2847,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2582,6 +2872,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2691,6 +2982,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -2699,6 +2991,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2723,6 +3016,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2758,6 +3052,176 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$x.a" + } +] +``` +### Results +```json +{ "_id" : 1, "count" : 2 } +{ "_id" : 2, "count" : 2 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "39062D46AC66A096B98DB7B9AD3C198F432183DF3436553F59C3EC8B5252F1EA", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$x.a", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 4. Example with two joins and sub-pipeline with un-correlated $match ### No join opt ### Pipeline @@ -2824,6 +3288,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -2946,6 +3411,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2955,6 +3421,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2972,6 +3439,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3054,6 +3522,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3063,6 +3532,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3072,6 +3542,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3162,6 +3633,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3171,6 +3643,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3188,6 +3661,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3272,6 +3746,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3279,6 +3754,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3296,6 +3772,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3380,6 +3857,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3387,6 +3865,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3404,6 +3883,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3488,6 +3968,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3495,6 +3976,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3512,6 +3994,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3596,6 +4079,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3603,6 +4087,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3620,6 +4105,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3634,6 +4120,143 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "6E1AD01BB023E5575DBF8997EA4E7E46A5BCCAA49D659AFD0AB18E0D1E797FF4", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 5. Example with two joins, suffix, and sub-pipeline with un-correlated $match and $match prefix ### No join opt ### Pipeline @@ -3712,6 +4335,7 @@ Execution Engine: classic "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "isCached" : false, @@ -3873,6 +4497,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -3889,6 +4514,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3906,6 +4532,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4019,6 +4646,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4031,6 +4659,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4047,6 +4676,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4171,6 +4801,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4187,6 +4818,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4204,6 +4836,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4319,6 +4952,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -4329,6 +4963,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4353,6 +4988,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4468,6 +5104,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -4478,6 +5115,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4502,6 +5140,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4617,6 +5256,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4627,6 +5267,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4651,6 +5292,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4766,6 +5408,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4776,6 +5419,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4800,6 +5444,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4835,6 +5480,184 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$match" : { + "a" : { + "$gt" : 1 + } + } + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$x.a" + } +] +``` +### Results +```json +{ "_id" : 2, "count" : 2 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "7D59BE511C0D33652DB26A61DFFA0D36F47580971FB97DF9C3C4BC3A3F52F932", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + "a" : { + "$gt" : 1 + } + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$x.a", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 6. Example with two joins and sub-pipeline with un-correlated $match and $match prefix ### No join opt ### Pipeline @@ -4911,6 +5734,7 @@ Execution Engine: classic } }, "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -5040,6 +5864,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5049,6 +5874,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5066,6 +5892,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5153,6 +5980,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5164,6 +5992,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5173,6 +6002,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5270,6 +6100,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5279,6 +6110,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5296,6 +6128,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5385,6 +6218,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -5394,6 +6228,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5411,6 +6246,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5500,6 +6336,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -5509,6 +6346,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5526,6 +6364,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5615,6 +6454,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5624,6 +6464,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5641,6 +6482,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5730,6 +6572,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5739,6 +6582,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5756,6 +6600,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5770,6 +6615,150 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$match" : { + "a" : { + "$gt" : 1 + } + } + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "D2D2550CF530351E25FFDB1BB9DBD96DD0CE98C0FA4082BADF1F9BC9F7579A03", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "direction" : "forward", + "filter" : { + "a" : { + "$gt" : 1 + } + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 7. Basic example with referencing field from previous lookup ### No join opt ### Pipeline @@ -5818,6 +6807,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -5898,6 +6888,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5905,6 +6896,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5920,6 +6912,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -5982,6 +6975,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -5991,6 +6985,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5998,6 +6993,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6070,6 +7066,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6077,6 +7074,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6092,6 +7090,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6156,6 +7155,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -6163,6 +7163,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6178,6 +7179,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6242,6 +7244,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -6249,6 +7252,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6264,6 +7268,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6328,6 +7333,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6335,6 +7341,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6350,6 +7357,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6414,6 +7422,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6421,6 +7430,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6436,6 +7446,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6450,6 +7461,95 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 0, "a" : 1, "b" : "foo", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DC5CAF413E9B6B8B5E8B2D3FB91E4D546524BF2707BBE30472D5CA8E12F6637E", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "z", + "rightEmbeddingField" : "x", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 5, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 8. Basic example with 3 joins & subsequent join referencing fields from previous lookups ### No join opt ### Pipeline @@ -6511,6 +7611,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -6617,6 +7718,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6624,6 +7726,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6639,6 +7742,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -6654,6 +7758,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6729,6 +7834,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6738,6 +7844,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -6747,6 +7854,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6754,6 +7862,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6845,6 +7954,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6856,6 +7966,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6863,6 +7974,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6878,6 +7990,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -6965,6 +8078,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6972,6 +8086,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6987,6 +8102,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7002,6 +8118,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7081,6 +8198,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7088,6 +8206,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7103,6 +8222,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7118,6 +8238,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7197,6 +8318,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -7204,6 +8326,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7219,6 +8342,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -7234,6 +8358,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7313,6 +8438,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -7320,6 +8446,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7335,6 +8462,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -7350,6 +8478,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7364,6 +8493,134 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DD24FFAE1F16C6C1F5B03939E0C642A797120A2585058C72554C9649BEA427AB", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "y", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 9. Basic example with 3 joins & subsequent join referencing nested paths ### No join opt ### Pipeline @@ -7420,6 +8677,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -7521,6 +8779,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7528,6 +8787,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7543,6 +8803,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7558,6 +8819,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7628,6 +8890,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -7637,6 +8900,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -7646,6 +8910,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7653,6 +8918,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7739,6 +9005,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -7750,6 +9017,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7757,6 +9025,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7772,6 +9041,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7854,6 +9124,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7861,6 +9132,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7876,6 +9148,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7891,6 +9164,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7965,6 +9239,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7972,6 +9247,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7987,6 +9263,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8002,6 +9279,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8076,6 +9354,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -8083,6 +9362,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8098,6 +9378,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8113,6 +9394,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -8187,6 +9469,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -8194,6 +9477,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8209,6 +9493,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8224,6 +9509,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -8238,3 +9524,118 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "w.y", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$w.y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "k.y.z", + "localField" : "w.y.d", + "foreignField" : "d" + } + }, + { + "$unwind" : "$k.y.z" + } +] +``` +### Results +```json +{ "_id" : 2, "a" : 2, "b" : "bar", "k" : { "y" : { "z" : { "_id" : 0, "b" : "bar", "d" : 2 } } }, "w" : { "y" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } }, "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "9226A4FAA10C8790B27D9B5B865D46D0C58179A837F014E6289A34A6EBE76420", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "w.y", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "w.y.d = d" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "k.y.z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + diff --git a/jstests/query_golden/expected_output/sbeDisabled/distinct_aggregation_multiplanning.md b/jstests/query_golden/expected_output/sbeDisabled/distinct_aggregation_multiplanning.md index 3000b63d511..5aa1d8b3f06 100644 --- a/jstests/query_golden/expected_output/sbeDisabled/distinct_aggregation_multiplanning.md +++ b/jstests/query_golden/expected_output/sbeDisabled/distinct_aggregation_multiplanning.md @@ -2025,6 +2025,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2328,6 +2329,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2403,6 +2405,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -2921,6 +2924,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2941,6 +2945,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -2978,6 +2983,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2998,6 +3004,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3035,6 +3042,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3055,6 +3063,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3097,6 +3106,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3117,6 +3127,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3584,6 +3595,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-2", "stage" : "IXSCAN" } ] @@ -3751,6 +3763,7 @@ Execution Engine: classic "$gt" : 0 } }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "FETCH" }, { @@ -3776,6 +3789,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "IXSCAN" } ] @@ -3851,6 +3865,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -3876,6 +3891,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3890,6 +3906,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -3922,6 +3939,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3964,6 +3982,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4038,6 +4057,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4063,6 +4083,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -4077,6 +4098,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4109,6 +4131,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4151,6 +4174,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4220,6 +4244,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4252,6 +4277,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -4265,6 +4291,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4299,6 +4326,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4313,6 +4341,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4340,6 +4369,7 @@ Execution Engine: classic ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4387,6 +4417,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -4448,6 +4479,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeDisabled/distinct_command_multiplanning.md b/jstests/query_golden/expected_output/sbeDisabled/distinct_command_multiplanning.md index 2ebea3dd08a..1bed6fe1391 100644 --- a/jstests/query_golden/expected_output/sbeDisabled/distinct_command_multiplanning.md +++ b/jstests/query_golden/expected_output/sbeDisabled/distinct_command_multiplanning.md @@ -14,6 +14,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -34,6 +35,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -44,6 +46,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -64,6 +67,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -75,6 +79,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -100,6 +105,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -117,6 +123,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -139,12 +146,14 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -167,6 +176,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -188,6 +198,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -210,6 +221,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -220,6 +232,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -242,6 +255,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -253,6 +267,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -278,6 +293,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -798,6 +814,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -823,6 +840,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -865,6 +883,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -890,6 +909,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -927,6 +947,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -952,6 +973,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -994,6 +1016,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1019,6 +1042,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1061,6 +1085,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1086,6 +1111,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1128,6 +1154,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1153,6 +1180,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1543,6 +1571,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1563,6 +1592,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1573,6 +1603,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1598,6 +1629,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1693,6 +1725,7 @@ "$lt" : 105 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1713,6 +1746,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1724,6 +1758,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1749,6 +1784,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1911,6 +1947,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1931,6 +1968,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1963,6 +2001,7 @@ } ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeDisabled/distinct_index_eligibility.md b/jstests/query_golden/expected_output/sbeDisabled/distinct_index_eligibility.md index f2f7b6bf3e5..b785fa60509 100644 --- a/jstests/query_golden/expected_output/sbeDisabled/distinct_index_eligibility.md +++ b/jstests/query_golden/expected_output/sbeDisabled/distinct_index_eligibility.md @@ -42,6 +42,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -69,6 +70,7 @@ Execution Engine: classic ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] @@ -215,6 +217,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -395,6 +398,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -448,6 +452,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -513,6 +518,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -804,6 +810,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -1020,6 +1027,7 @@ Execution Engine: classic "$lt" : 3 } }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -1037,6 +1045,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -1062,6 +1071,7 @@ Execution Engine: classic "$_path" : [ ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeDisabled/distinct_query_planner.md b/jstests/query_golden/expected_output/sbeDisabled/distinct_query_planner.md index 42499906a72..72cdae17712 100644 --- a/jstests/query_golden/expected_output/sbeDisabled/distinct_query_planner.md +++ b/jstests/query_golden/expected_output/sbeDisabled/distinct_query_planner.md @@ -214,6 +214,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] @@ -290,6 +291,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_query_planner_md", "stage" : "FETCH" }, { @@ -310,6 +312,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_query_planner_md", "stage" : "IXSCAN" } ] @@ -427,6 +430,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeDisabled/distinct_scan.md b/jstests/query_golden/expected_output/sbeDisabled/distinct_scan.md index 9ff8ca84e9a..b08437bf8ce 100644 --- a/jstests/query_golden/expected_output/sbeDisabled/distinct_scan.md +++ b/jstests/query_golden/expected_output/sbeDisabled/distinct_scan.md @@ -10,6 +10,7 @@ "winningPlan" : [ { "direction" : "forward", + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -48,6 +49,7 @@ Execution Engine: classic }, { "direction" : "forward", + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -701,6 +703,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -721,6 +724,7 @@ Execution Engine: classic "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] @@ -766,6 +770,7 @@ Execution Engine: classic } }, { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -786,6 +791,7 @@ Execution Engine: classic "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeFull/base_coll_reorder.md b/jstests/query_golden/expected_output/sbeFull/base_coll_reorder.md index 710a347ae3e..82f15238ca8 100644 --- a/jstests/query_golden/expected_output/sbeFull/base_coll_reorder.md +++ b/jstests/query_golden/expected_output/sbeFull/base_coll_reorder.md @@ -63,6 +63,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" }, "localField" : "a", @@ -166,6 +167,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" }, "localField" : "a", @@ -264,6 +266,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" }, "localField" : "base", @@ -394,6 +397,7 @@ Execution Engine: sbe "$eq" : 3 } }, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" }, "localField" : "base", @@ -590,6 +594,7 @@ Execution Engine: sbe "$eq" : 3 } }, + "nss" : "test.base_coll_reorder_md_base", "planNodeId" : 1, "stage" : "COLLSCAN" } diff --git a/jstests/query_golden/expected_output/sbeFull/basic_joins.md b/jstests/query_golden/expected_output/sbeFull/basic_joins.md index bff536e1435..eed3297163d 100644 --- a/jstests/query_golden/expected_output/sbeFull/basic_joins.md +++ b/jstests/query_golden/expected_output/sbeFull/basic_joins.md @@ -55,6 +55,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -123,6 +124,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -130,6 +132,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -145,6 +148,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -209,6 +213,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -218,6 +223,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -225,6 +231,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -299,6 +306,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -306,6 +314,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -321,6 +330,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -387,6 +397,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -394,6 +405,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -409,6 +421,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -475,6 +488,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -482,6 +496,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -497,6 +512,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -563,6 +579,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -570,6 +587,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -585,6 +603,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -651,6 +670,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -658,6 +678,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -673,6 +694,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -687,6 +709,105 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "2312073BEBB7A5E1754E2D03D9CB40B75C126DBF60867D4639E7E281C9E3DFAC", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 6, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 2. Basic example with two joins and suffix ### No join opt ### Pipeline @@ -745,6 +866,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -831,6 +953,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -845,6 +968,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -860,6 +984,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -946,6 +1071,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -956,6 +1082,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -970,6 +1097,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1067,6 +1195,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1081,6 +1210,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1096,6 +1226,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1184,6 +1315,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1192,6 +1324,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1214,6 +1347,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1302,6 +1436,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1310,6 +1445,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1332,6 +1468,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1420,6 +1557,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1428,6 +1566,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1450,6 +1589,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1538,6 +1678,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1546,6 +1687,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1568,6 +1710,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1603,6 +1746,135 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$y.b" + } +] +``` +### Results +```json +{ "_id" : "bar", "count" : 6 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "8E0DF14D3DA69D8B1CF0361E869369F9C5E5F2F2A5D81998E6800BDA4F997B57", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$y.b", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 3. Example with two joins, suffix, and sub-pipeline with un-correlated $match ### No join opt ### Pipeline @@ -1673,6 +1945,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "planNodeId" : 2, @@ -1826,6 +2099,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1842,6 +2116,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1859,6 +2134,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1966,6 +2242,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1976,6 +2253,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1992,6 +2270,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2108,6 +2387,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2124,6 +2404,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2141,6 +2422,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2250,6 +2532,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -2258,6 +2541,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2282,6 +2566,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2391,6 +2676,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -2399,6 +2685,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2423,6 +2710,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2532,6 +2820,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -2540,6 +2829,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2564,6 +2854,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2673,6 +2964,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -2681,6 +2973,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2705,6 +2998,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2740,6 +3034,176 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$x.a" + } +] +``` +### Results +```json +{ "_id" : 1, "count" : 2 } +{ "_id" : 2, "count" : 2 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "39062D46AC66A096B98DB7B9AD3C198F432183DF3436553F59C3EC8B5252F1EA", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$x.a", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 4. Example with two joins and sub-pipeline with un-correlated $match ### No join opt ### Pipeline @@ -2808,6 +3272,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "planNodeId" : 1, "stage" : "COLLSCAN" } @@ -2931,6 +3396,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2940,6 +3406,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2957,6 +3424,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3039,6 +3507,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3048,6 +3517,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3057,6 +3527,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3147,6 +3618,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3156,6 +3628,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3173,6 +3646,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3257,6 +3731,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3264,6 +3739,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3281,6 +3757,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3365,6 +3842,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3372,6 +3850,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3389,6 +3868,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3473,6 +3953,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3480,6 +3961,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3497,6 +3979,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3581,6 +4064,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3588,6 +4072,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3605,6 +4090,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3619,6 +4105,143 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "6E1AD01BB023E5575DBF8997EA4E7E46A5BCCAA49D659AFD0AB18E0D1E797FF4", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 5. Example with two joins, suffix, and sub-pipeline with un-correlated $match and $match prefix ### No join opt ### Pipeline @@ -3697,6 +4320,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "planNodeId" : 2, @@ -3858,6 +4482,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -3874,6 +4499,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3891,6 +4517,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4004,6 +4631,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4016,6 +4644,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4032,6 +4661,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4156,6 +4786,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4172,6 +4803,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4189,6 +4821,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4304,6 +4937,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -4314,6 +4948,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4338,6 +4973,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4453,6 +5089,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -4463,6 +5100,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4487,6 +5125,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4602,6 +5241,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4612,6 +5252,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4636,6 +5277,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4751,6 +5393,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4761,6 +5404,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4785,6 +5429,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4820,6 +5465,184 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$match" : { + "a" : { + "$gt" : 1 + } + } + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$x.a" + } +] +``` +### Results +```json +{ "_id" : 2, "count" : 2 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "7D59BE511C0D33652DB26A61DFFA0D36F47580971FB97DF9C3C4BC3A3F52F932", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + "a" : { + "$gt" : 1 + } + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$x.a", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 6. Example with two joins and sub-pipeline with un-correlated $match and $match prefix ### No join opt ### Pipeline @@ -4895,6 +5718,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "planNodeId" : 1, "stage" : "COLLSCAN" } @@ -5025,6 +5849,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5034,6 +5859,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5051,6 +5877,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5138,6 +5965,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5149,6 +5977,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5158,6 +5987,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5255,6 +6085,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5264,6 +6095,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5281,6 +6113,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5370,6 +6203,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -5379,6 +6213,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5396,6 +6231,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5485,6 +6321,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -5494,6 +6331,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5511,6 +6349,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5600,6 +6439,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5609,6 +6449,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5626,6 +6467,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5715,6 +6557,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5724,6 +6567,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5741,6 +6585,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5755,6 +6600,150 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$match" : { + "a" : { + "$gt" : 1 + } + } + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "D2D2550CF530351E25FFDB1BB9DBD96DD0CE98C0FA4082BADF1F9BC9F7579A03", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "direction" : "forward", + "filter" : { + "a" : { + "$gt" : 1 + } + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 7. Basic example with referencing field from previous lookup ### No join opt ### Pipeline @@ -5810,6 +6799,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -5876,6 +6866,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5883,6 +6874,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5898,6 +6890,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -5960,6 +6953,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -5969,6 +6963,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5976,6 +6971,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6048,6 +7044,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6055,6 +7052,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6070,6 +7068,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6134,6 +7133,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -6141,6 +7141,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6156,6 +7157,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6220,6 +7222,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -6227,6 +7230,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6242,6 +7246,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6306,6 +7311,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6313,6 +7319,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6328,6 +7335,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6392,6 +7400,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6399,6 +7408,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6414,6 +7424,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6428,6 +7439,95 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 0, "a" : 1, "b" : "foo", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DC5CAF413E9B6B8B5E8B2D3FB91E4D546524BF2707BBE30472D5CA8E12F6637E", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "z", + "rightEmbeddingField" : "x", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 5, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 8. Basic example with 3 joins & subsequent join referencing fields from previous lookups ### No join opt ### Pipeline @@ -6500,6 +7600,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -6586,6 +7687,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6593,6 +7695,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6608,6 +7711,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -6623,6 +7727,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6698,6 +7803,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6707,6 +7813,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -6716,6 +7823,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6723,6 +7831,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6814,6 +7923,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6825,6 +7935,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6832,6 +7943,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6847,6 +7959,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -6934,6 +8047,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6941,6 +8055,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6956,6 +8071,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6971,6 +8087,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7050,6 +8167,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7057,6 +8175,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7072,6 +8191,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7087,6 +8207,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7166,6 +8287,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -7173,6 +8295,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7188,6 +8311,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -7203,6 +8327,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7282,6 +8407,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -7289,6 +8415,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7304,6 +8431,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -7319,6 +8447,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7333,6 +8462,134 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DD24FFAE1F16C6C1F5B03939E0C642A797120A2585058C72554C9649BEA427AB", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "y", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 9. Basic example with 3 joins & subsequent join referencing nested paths ### No join opt ### Pipeline @@ -7400,6 +8657,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "localField" : "a", @@ -7481,6 +8739,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7488,6 +8747,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7503,6 +8763,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7518,6 +8779,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7588,6 +8850,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -7597,6 +8860,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -7606,6 +8870,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7613,6 +8878,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7699,6 +8965,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -7710,6 +8977,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7717,6 +8985,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7732,6 +9001,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7814,6 +9084,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7821,6 +9092,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7836,6 +9108,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7851,6 +9124,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7925,6 +9199,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7932,6 +9207,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7947,6 +9223,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7962,6 +9239,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8036,6 +9314,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -8043,6 +9322,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8058,6 +9338,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8073,6 +9354,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -8147,6 +9429,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -8154,6 +9437,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8169,6 +9453,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8184,6 +9469,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -8198,3 +9484,118 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "w.y", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$w.y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "k.y.z", + "localField" : "w.y.d", + "foreignField" : "d" + } + }, + { + "$unwind" : "$k.y.z" + } +] +``` +### Results +```json +{ "_id" : 2, "a" : 2, "b" : "bar", "k" : { "y" : { "z" : { "_id" : 0, "b" : "bar", "d" : 2 } } }, "w" : { "y" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } }, "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "9226A4FAA10C8790B27D9B5B865D46D0C58179A837F014E6289A34A6EBE76420", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "w.y", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "w.y.d = d" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "k.y.z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + diff --git a/jstests/query_golden/expected_output/sbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md b/jstests/query_golden/expected_output/sbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md index d2bbea0b1cd..60906beae47 100644 --- a/jstests/query_golden/expected_output/sbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md +++ b/jstests/query_golden/expected_output/sbeFull/cached_partial_index_plan_not_reused_for_ineligible_query.md @@ -144,9 +144,11 @@ Creating Index "$lte" : 5 } }, + "nss" : "test.cached_partial_index_plan_not_reused_for_ineligible_query_md", "inputStage" : { "stage" : "IXSCAN", "planNodeId" : 1, + "nss" : "test.cached_partial_index_plan_not_reused_for_ineligible_query_md", "keyPattern" : { "a" : 1 }, diff --git a/jstests/query_golden/expected_output/sbeFull/distinct_aggregation_multiplanning.md b/jstests/query_golden/expected_output/sbeFull/distinct_aggregation_multiplanning.md index 21d5a3d41c7..be4bc87f255 100644 --- a/jstests/query_golden/expected_output/sbeFull/distinct_aggregation_multiplanning.md +++ b/jstests/query_golden/expected_output/sbeFull/distinct_aggregation_multiplanning.md @@ -2025,6 +2025,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2328,6 +2329,7 @@ Execution Engine: sbe "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2394,6 +2396,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -2900,6 +2903,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2920,6 +2924,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -2957,6 +2962,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2977,6 +2983,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3014,6 +3021,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3034,6 +3042,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3076,6 +3085,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3096,6 +3106,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3215,6 +3226,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3235,6 +3247,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3309,6 +3322,7 @@ Execution Engine: sbe "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3329,6 +3343,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3400,6 +3415,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3425,6 +3441,7 @@ Execution Engine: sbe "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3506,6 +3523,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-2", "stage" : "IXSCAN" } ] @@ -3673,6 +3691,7 @@ Execution Engine: classic "$gt" : 0 } }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "FETCH" }, { @@ -3698,6 +3717,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "IXSCAN" } ] @@ -3886,6 +3906,7 @@ Execution Engine: sbe "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4055,6 +4076,7 @@ Execution Engine: sbe "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4191,6 +4213,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4218,6 +4241,7 @@ Execution Engine: sbe ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4249,6 +4273,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -4296,6 +4321,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeFull/distinct_command_multiplanning.md b/jstests/query_golden/expected_output/sbeFull/distinct_command_multiplanning.md index f4ec46357ae..212717be244 100644 --- a/jstests/query_golden/expected_output/sbeFull/distinct_command_multiplanning.md +++ b/jstests/query_golden/expected_output/sbeFull/distinct_command_multiplanning.md @@ -75,6 +75,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -100,6 +101,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -145,6 +147,7 @@ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -167,6 +170,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -253,6 +257,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -278,6 +283,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -798,6 +804,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -823,6 +830,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -865,6 +873,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -890,6 +899,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -927,6 +937,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -952,6 +963,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -994,6 +1006,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1019,6 +1032,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1061,6 +1075,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1086,6 +1101,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1128,6 +1144,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1153,6 +1170,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1371,6 +1389,7 @@ "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1399,6 +1418,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1424,6 +1444,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1456,6 +1477,7 @@ "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1484,6 +1506,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1515,6 +1538,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1537,6 +1561,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1557,6 +1582,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1567,6 +1593,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1592,6 +1619,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1687,6 +1715,7 @@ "$lt" : 105 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1707,6 +1736,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1718,6 +1748,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1743,6 +1774,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1776,6 +1808,7 @@ "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1799,6 +1832,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1807,6 +1841,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1832,6 +1867,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1902,6 +1938,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1922,6 +1959,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1954,6 +1992,7 @@ } ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeFull/distinct_index_eligibility.md b/jstests/query_golden/expected_output/sbeFull/distinct_index_eligibility.md index 2dd0056e142..551c70650ad 100644 --- a/jstests/query_golden/expected_output/sbeFull/distinct_index_eligibility.md +++ b/jstests/query_golden/expected_output/sbeFull/distinct_index_eligibility.md @@ -34,6 +34,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -61,6 +62,7 @@ Execution Engine: sbe ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] @@ -190,6 +192,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -348,6 +351,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -387,6 +391,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -443,6 +448,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -728,6 +734,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -932,6 +939,7 @@ Execution Engine: classic "$lt" : 3 } }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -949,6 +957,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -974,6 +983,7 @@ Execution Engine: classic "$_path" : [ ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeFull/distinct_query_planner.md b/jstests/query_golden/expected_output/sbeFull/distinct_query_planner.md index 8c00ea6e05b..dcd30eeda12 100644 --- a/jstests/query_golden/expected_output/sbeFull/distinct_query_planner.md +++ b/jstests/query_golden/expected_output/sbeFull/distinct_query_planner.md @@ -209,6 +209,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] @@ -259,6 +260,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_query_planner_md", "stage" : "FETCH" }, { @@ -279,6 +281,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_query_planner_md", "stage" : "IXSCAN" } ] @@ -374,6 +377,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeFull/distinct_scan.md b/jstests/query_golden/expected_output/sbeFull/distinct_scan.md index 8f97c236a4e..3b10c81beec 100644 --- a/jstests/query_golden/expected_output/sbeFull/distinct_scan.md +++ b/jstests/query_golden/expected_output/sbeFull/distinct_scan.md @@ -13,6 +13,7 @@ "filter" : { }, + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -47,6 +48,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -691,6 +693,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -711,6 +714,7 @@ Execution Engine: classic "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] @@ -749,6 +753,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -769,6 +774,7 @@ Execution Engine: sbe "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeFull/expr_in_rewrite.md b/jstests/query_golden/expected_output/sbeFull/expr_in_rewrite.md index ca7317bcabe..8578bdb4955 100644 --- a/jstests/query_golden/expected_output/sbeFull/expr_in_rewrite.md +++ b/jstests/query_golden/expected_output/sbeFull/expr_in_rewrite.md @@ -38,6 +38,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -79,6 +80,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -101,6 +103,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -146,6 +149,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -195,6 +199,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -217,6 +222,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -260,6 +266,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -307,6 +314,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -330,6 +338,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -376,6 +385,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -428,6 +438,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -451,6 +462,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -497,6 +509,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -549,6 +562,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -572,6 +586,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -617,6 +632,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -668,6 +684,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -691,6 +708,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -738,6 +756,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -792,6 +811,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -815,6 +835,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -863,6 +884,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -919,6 +941,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -942,6 +965,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -990,6 +1014,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1047,6 +1072,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1070,6 +1096,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1119,6 +1146,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1178,6 +1206,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1201,6 +1230,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1246,6 +1276,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1286,6 +1317,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1308,6 +1340,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1355,6 +1388,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1410,6 +1444,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1433,6 +1468,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1478,6 +1514,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1518,6 +1555,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1540,6 +1578,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1587,6 +1626,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1642,6 +1682,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1665,6 +1706,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1711,6 +1753,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1752,6 +1795,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1774,6 +1818,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1821,6 +1866,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1876,6 +1922,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -1899,6 +1946,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -1942,6 +1990,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -1980,6 +2029,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2002,6 +2052,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2045,6 +2096,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2083,6 +2135,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2105,6 +2158,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2149,6 +2203,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2188,6 +2243,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2210,6 +2266,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2255,6 +2312,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2306,6 +2364,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2329,6 +2388,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2374,6 +2434,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2425,6 +2486,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2448,6 +2510,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2493,6 +2556,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2544,6 +2608,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2567,6 +2632,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2612,6 +2678,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2663,6 +2730,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2686,6 +2754,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2731,6 +2800,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2782,6 +2852,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2805,6 +2876,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2850,6 +2922,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -2901,6 +2974,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -2924,6 +2998,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -2974,6 +3049,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3019,6 +3095,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3041,6 +3118,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3101,6 +3179,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3156,6 +3235,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3179,6 +3259,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3251,6 +3332,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3344,6 +3426,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3427,6 +3510,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3505,6 +3589,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3528,6 +3613,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3597,6 +3683,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3661,6 +3748,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3684,6 +3772,7 @@ Summarized explain "m" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3728,6 +3817,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3767,6 +3857,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3790,6 +3881,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3835,6 +3927,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -3886,6 +3979,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -3910,6 +4004,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -3957,6 +4052,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4012,6 +4108,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4036,6 +4133,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4079,6 +4177,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4126,6 +4225,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4150,6 +4250,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4195,6 +4296,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4246,6 +4348,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4270,6 +4373,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4315,6 +4419,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4355,6 +4460,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4378,6 +4484,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4425,6 +4532,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4480,6 +4588,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4504,6 +4613,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4547,6 +4657,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4594,6 +4705,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4617,6 +4729,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] @@ -4662,6 +4775,7 @@ Summarized explain ] } }, + "nss" : "test.expr_in_rewrite_md", "stage" : "COLLSCAN" } ] @@ -4713,6 +4827,7 @@ Summarized explain } ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "FETCH" }, { @@ -4737,6 +4852,7 @@ Summarized explain "m.a" ] }, + "nss" : "test.expr_in_rewrite_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeRestricted/base_coll_reorder.md b/jstests/query_golden/expected_output/sbeRestricted/base_coll_reorder.md index 0af6dfa2e9c..05c04270cce 100644 --- a/jstests/query_golden/expected_output/sbeRestricted/base_coll_reorder.md +++ b/jstests/query_golden/expected_output/sbeRestricted/base_coll_reorder.md @@ -55,6 +55,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -164,6 +165,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -268,6 +270,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -405,6 +408,7 @@ Execution Engine: classic } }, "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } @@ -613,6 +617,7 @@ Execution Engine: classic } }, "isCached" : false, + "nss" : "test.base_coll_reorder_md_base", "stage" : "COLLSCAN" } } diff --git a/jstests/query_golden/expected_output/sbeRestricted/basic_joins.md b/jstests/query_golden/expected_output/sbeRestricted/basic_joins.md index 7c25e224d2d..2cbde4ae49f 100644 --- a/jstests/query_golden/expected_output/sbeRestricted/basic_joins.md +++ b/jstests/query_golden/expected_output/sbeRestricted/basic_joins.md @@ -48,6 +48,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -130,6 +131,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -137,6 +139,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -152,6 +155,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -216,6 +220,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -225,6 +230,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -232,6 +238,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -306,6 +313,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -313,6 +321,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -328,6 +337,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -394,6 +404,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -401,6 +412,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -416,6 +428,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -482,6 +495,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -489,6 +503,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -504,6 +519,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -570,6 +586,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -577,6 +594,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -592,6 +610,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -658,6 +677,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -665,6 +685,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -680,6 +701,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -694,6 +716,105 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "2312073BEBB7A5E1754E2D03D9CB40B75C126DBF60867D4639E7E281C9E3DFAC", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 6, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 2. Basic example with two joins and suffix ### No join opt ### Pipeline @@ -742,6 +863,7 @@ Execution Engine: classic "winningPlan" : { "inputStage" : { "direction" : "forward", + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "isCached" : false, @@ -852,6 +974,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -866,6 +989,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -881,6 +1005,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -967,6 +1092,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -977,6 +1103,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -991,6 +1118,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1088,6 +1216,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1102,6 +1231,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1117,6 +1247,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1205,6 +1336,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1213,6 +1345,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1235,6 +1368,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1323,6 +1457,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -1331,6 +1466,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1353,6 +1489,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1441,6 +1578,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1449,6 +1587,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1471,6 +1610,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1559,6 +1699,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1567,6 +1708,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1589,6 +1731,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1624,6 +1767,135 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$y.b" + } +] +``` +### Results +```json +{ "_id" : "bar", "count" : 6 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "8E0DF14D3DA69D8B1CF0361E869369F9C5E5F2F2A5D81998E6800BDA4F997B57", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$y.b", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 3. Example with two joins, suffix, and sub-pipeline with un-correlated $match ### No join opt ### Pipeline @@ -1691,6 +1963,7 @@ Execution Engine: classic "winningPlan" : { "inputStage" : { "direction" : "forward", + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "isCached" : false, @@ -1844,6 +2117,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -1860,6 +2134,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -1877,6 +2152,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -1984,6 +2260,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -1994,6 +2271,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2010,6 +2288,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2126,6 +2405,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2142,6 +2422,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2159,6 +2440,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2268,6 +2550,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -2276,6 +2559,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2300,6 +2584,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2409,6 +2694,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -2417,6 +2703,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2441,6 +2728,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -2550,6 +2838,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -2558,6 +2847,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2582,6 +2872,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2691,6 +2982,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -2699,6 +2991,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -2723,6 +3016,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2758,6 +3052,176 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$x.a" + } +] +``` +### Results +```json +{ "_id" : 1, "count" : 2 } +{ "_id" : 2, "count" : 2 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "39062D46AC66A096B98DB7B9AD3C198F432183DF3436553F59C3EC8B5252F1EA", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$x.a", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 4. Example with two joins and sub-pipeline with un-correlated $match ### No join opt ### Pipeline @@ -2824,6 +3288,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -2946,6 +3411,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -2955,6 +3421,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -2972,6 +3439,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3054,6 +3522,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3063,6 +3532,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3072,6 +3542,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3162,6 +3633,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -3171,6 +3643,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3188,6 +3661,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3272,6 +3746,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3279,6 +3754,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3296,6 +3772,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3380,6 +3857,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -3387,6 +3865,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3404,6 +3883,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -3488,6 +3968,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3495,6 +3976,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3512,6 +3994,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3596,6 +4079,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -3603,6 +4087,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -3620,6 +4105,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3634,6 +4120,143 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "6E1AD01BB023E5575DBF8997EA4E7E46A5BCCAA49D659AFD0AB18E0D1E797FF4", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 5. Example with two joins, suffix, and sub-pipeline with un-correlated $match and $match prefix ### No join opt ### Pipeline @@ -3712,6 +4335,7 @@ Execution Engine: classic "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "isCached" : false, @@ -3873,6 +4497,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -3889,6 +4514,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -3906,6 +4532,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4019,6 +4646,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4031,6 +4659,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4047,6 +4676,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4171,6 +4801,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4187,6 +4818,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4204,6 +4836,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4319,6 +4952,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -4329,6 +4963,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4353,6 +4988,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4468,6 +5104,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -4478,6 +5115,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4502,6 +5140,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -4617,6 +5256,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4627,6 +5267,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4651,6 +5292,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4766,6 +5408,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -4776,6 +5419,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, "stage" : "PROJECTION_SIMPLE", @@ -4800,6 +5444,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -4835,6 +5480,184 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$match" : { + "a" : { + "$gt" : 1 + } + } + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + }, + { + "$sortByCount" : "$x.a" + } +] +``` +### Results +```json +{ "_id" : 2, "count" : 2 } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "7D59BE511C0D33652DB26A61DFFA0D36F47580971FB97DF9C3C4BC3A3F52F932", + "stages" : [ + { + "$cursor" : { + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "inputStage" : { + "direction" : "forward", + "filter" : { + "a" : { + "$gt" : 1 + } + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + }, + "stage" : "PROJECTION_SIMPLE", + "transformBy" : { + "_id" : false, + "a" : true, + "b" : true + } + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } + } + }, + { + "$group" : { + "$willBeMerged" : false, + "_id" : "$x.a", + "count" : { + "$sum" : { + "$const" : 1 + } + } + } + }, + { + "$sort" : { + "sortKey" : { + "count" : -1 + } + } + } + ] +} +``` + ## 6. Example with two joins and sub-pipeline with un-correlated $match and $match prefix ### No join opt ### Pipeline @@ -4911,6 +5734,7 @@ Execution Engine: classic } }, "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -5040,6 +5864,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5049,6 +5874,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5066,6 +5892,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5153,6 +5980,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5164,6 +5992,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5173,6 +6002,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5270,6 +6100,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5279,6 +6110,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5296,6 +6128,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5385,6 +6218,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -5394,6 +6228,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5411,6 +6246,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5500,6 +6336,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -5509,6 +6346,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5526,6 +6364,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -5615,6 +6454,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5624,6 +6464,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5641,6 +6482,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5730,6 +6572,7 @@ Execution Engine: sbe "$gt" : "aaa" } }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -5739,6 +6582,7 @@ Execution Engine: sbe "$gt" : 1 } }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -5756,6 +6600,7 @@ Execution Engine: sbe "$lt" : 3 } }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5770,6 +6615,150 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$match" : { + "a" : { + "$gt" : 1 + } + } + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a", + "pipeline" : [ + { + "$match" : { + "d" : { + "$lt" : 3 + } + } + } + ] + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b", + "pipeline" : [ + { + "$match" : { + "b" : { + "$gt" : "aaa" + } + } + } + ] + } + }, + { + "$unwind" : "$y" + } +] +``` +### Results +```json +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "D2D2550CF530351E25FFDB1BB9DBD96DD0CE98C0FA4082BADF1F9BC9F7579A03", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStage" : { + "direction" : "forward", + "indexBounds" : { + "b" : [ + "(\"aaa\", {})" + ] + }, + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "multiKeyPaths" : { + "b" : [ ] + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "IXSCAN" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + }, + { + "direction" : "forward", + "filter" : { + "a" : { + "$gt" : 1 + } + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "y", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "filter" : { + "d" : { + "$lt" : 3 + } + }, + "inputStage" : { + "indexName" : "a_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "a" : 1 + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "x", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 7. Basic example with referencing field from previous lookup ### No join opt ### Pipeline @@ -5818,6 +6807,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -5898,6 +6888,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5905,6 +6896,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -5920,6 +6912,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -5982,6 +6975,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -5991,6 +6985,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -5998,6 +6993,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6070,6 +7066,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6077,6 +7074,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6092,6 +7090,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6156,6 +7155,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -6163,6 +7163,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6178,6 +7179,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6242,6 +7244,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -6249,6 +7252,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6264,6 +7268,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6328,6 +7333,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6335,6 +7341,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6350,6 +7357,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6414,6 +7422,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6421,6 +7430,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6436,6 +7446,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -6450,6 +7461,95 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 0, "a" : 1, "b" : "foo", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DC5CAF413E9B6B8B5E8B2D3FB91E4D546524BF2707BBE30472D5CA8E12F6637E", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "z", + "rightEmbeddingField" : "x", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 5, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 8. Basic example with 3 joins & subsequent join referencing fields from previous lookups ### No join opt ### Pipeline @@ -6511,6 +7611,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -6617,6 +7718,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6624,6 +7726,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6639,6 +7742,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -6654,6 +7758,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -6729,6 +7834,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6738,6 +7844,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -6747,6 +7854,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6754,6 +7862,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6845,6 +7954,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -6856,6 +7966,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6863,6 +7974,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6878,6 +7990,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -6965,6 +8078,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -6972,6 +8086,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -6987,6 +8102,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7002,6 +8118,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7081,6 +8198,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7088,6 +8206,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7103,6 +8222,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7118,6 +8238,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7197,6 +8318,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -7204,6 +8326,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7219,6 +8342,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -7234,6 +8358,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7313,6 +8438,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -7320,6 +8446,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7335,6 +8462,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -7350,6 +8478,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7364,6 +8493,134 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "y", + "localField" : "b", + "foreignField" : "b" + } + }, + { + "$unwind" : "$y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "z", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$z" + } +] +``` +### Results +```json +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 1, "a" : 1, "b" : "bar", "x" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 0, "a" : 1, "c" : "zoo", "d" : 1 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 0, "b" : "bar", "d" : 2 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +{ "_id" : 2, "a" : 2, "b" : "bar", "x" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 }, "y" : { "_id" : 1, "b" : "bar", "d" : 6 }, "z" : { "_id" : 2, "a" : 2, "c" : "x", "d" : 3 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "DD24FFAE1F16C6C1F5B03939E0C642A797120A2585058C72554C9649BEA427AB", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "inputStage" : { + "indexName" : "b_1", + "isMultiKey" : false, + "isPartial" : false, + "isSparse" : false, + "isUnique" : false, + "keyPattern" : { + "b" : 1 + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "INDEX_PROBE_NODE" + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "FETCH" + } + ], + "joinPredicates" : [ + "b = b" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 8, + "rightEmbeddingField" : "y", + "stage" : "INDEXED_NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + ## 9. Basic example with 3 joins & subsequent join referencing nested paths ### No join opt ### Pipeline @@ -7420,6 +8677,7 @@ Execution Engine: classic "winningPlan" : { "direction" : "forward", "isCached" : false, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } } @@ -7521,6 +8779,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7528,6 +8787,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7543,6 +8803,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7558,6 +8819,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7628,6 +8890,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -7637,6 +8900,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" }, { @@ -7646,6 +8910,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7653,6 +8918,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7739,6 +9005,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" }, { @@ -7750,6 +9017,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7757,6 +9025,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7772,6 +9041,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7854,6 +9124,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7861,6 +9132,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7876,6 +9148,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -7891,6 +9164,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -7965,6 +9239,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" }, { @@ -7972,6 +9247,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" } ], @@ -7987,6 +9263,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8002,6 +9279,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8076,6 +9354,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -8083,6 +9362,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8098,6 +9378,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8113,6 +9394,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -8187,6 +9469,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign1", "stage" : "COLLSCAN" }, { @@ -8194,6 +9477,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign3", "stage" : "COLLSCAN" } ], @@ -8209,6 +9493,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md_foreign2", "stage" : "COLLSCAN" } ], @@ -8224,6 +9509,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.basic_joins_md", "stage" : "COLLSCAN" } ], @@ -8238,3 +9524,118 @@ Execution Engine: sbe } ``` +### With fixed order, index join +### Pipeline +```json +[ + { + "$lookup" : { + "from" : "basic_joins_md_foreign1", + "as" : "x", + "localField" : "a", + "foreignField" : "a" + } + }, + { + "$unwind" : "$x" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign3", + "as" : "w.y", + "localField" : "x.c", + "foreignField" : "c" + } + }, + { + "$unwind" : "$w.y" + }, + { + "$lookup" : { + "from" : "basic_joins_md_foreign2", + "as" : "k.y.z", + "localField" : "w.y.d", + "foreignField" : "d" + } + }, + { + "$unwind" : "$k.y.z" + } +] +``` +### Results +```json +{ "_id" : 2, "a" : 2, "b" : "bar", "k" : { "y" : { "z" : { "_id" : 0, "b" : "bar", "d" : 2 } } }, "w" : { "y" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } }, "x" : { "_id" : 1, "a" : 2, "c" : "blah", "d" : 2 } } +``` +### Summarized explain +Execution Engine: sbe +```json +{ + "queryShapeHash" : "9226A4FAA10C8790B27D9B5B865D46D0C58179A837F014E6289A34A6EBE76420", + "rejectedPlans" : [ ], + "winningPlan" : { + "inputStages" : [ + { + "inputStages" : [ + { + "inputStages" : [ + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign1", + "stage" : "COLLSCAN" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign3", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "c = c" + ], + "leftEmbeddingField" : "x", + "rightEmbeddingField" : "w.y", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md_foreign2", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "w.y.d = d" + ], + "leftEmbeddingField" : "none", + "rightEmbeddingField" : "k.y.z", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + }, + { + "direction" : "forward", + "filter" : { + + }, + "nss" : "test.basic_joins_md", + "stage" : "COLLSCAN" + } + ], + "joinPredicates" : [ + "x.a = a" + ], + "leftEmbeddingField" : "none", + "planNodeId" : 7, + "rightEmbeddingField" : "none", + "stage" : "NESTED_LOOP_JOIN_EMBEDDING" + } +} +``` + diff --git a/jstests/query_golden/expected_output/sbeRestricted/distinct_aggregation_multiplanning.md b/jstests/query_golden/expected_output/sbeRestricted/distinct_aggregation_multiplanning.md index 21d5a3d41c7..be4bc87f255 100644 --- a/jstests/query_golden/expected_output/sbeRestricted/distinct_aggregation_multiplanning.md +++ b/jstests/query_golden/expected_output/sbeRestricted/distinct_aggregation_multiplanning.md @@ -2025,6 +2025,7 @@ Execution Engine: classic "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2328,6 +2329,7 @@ Execution Engine: sbe "d" ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -2394,6 +2396,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -2900,6 +2903,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2920,6 +2924,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -2957,6 +2962,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -2977,6 +2983,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3014,6 +3021,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3034,6 +3042,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ], @@ -3076,6 +3085,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3096,6 +3106,7 @@ Execution Engine: classic "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3215,6 +3226,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3235,6 +3247,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3309,6 +3322,7 @@ Execution Engine: sbe "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3329,6 +3343,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3400,6 +3415,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" }, { @@ -3425,6 +3441,7 @@ Execution Engine: sbe "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -3506,6 +3523,7 @@ Execution Engine: classic "a" : [ ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-2", "stage" : "IXSCAN" } ] @@ -3673,6 +3691,7 @@ Execution Engine: classic "$gt" : 0 } }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "FETCH" }, { @@ -3698,6 +3717,7 @@ Execution Engine: classic "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md-3", "stage" : "IXSCAN" } ] @@ -3886,6 +3906,7 @@ Execution Engine: sbe "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4055,6 +4076,7 @@ Execution Engine: sbe "b" : [ ], "c" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4191,6 +4213,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "FETCH" }, { @@ -4218,6 +4241,7 @@ Execution Engine: sbe ], "b" : [ ] }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "IXSCAN" } ] @@ -4249,6 +4273,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] @@ -4296,6 +4321,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_aggregation_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeRestricted/distinct_command_multiplanning.md b/jstests/query_golden/expected_output/sbeRestricted/distinct_command_multiplanning.md index 2ebea3dd08a..1bed6fe1391 100644 --- a/jstests/query_golden/expected_output/sbeRestricted/distinct_command_multiplanning.md +++ b/jstests/query_golden/expected_output/sbeRestricted/distinct_command_multiplanning.md @@ -14,6 +14,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -34,6 +35,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -44,6 +46,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -64,6 +67,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -75,6 +79,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -100,6 +105,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -117,6 +123,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -139,12 +146,14 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] ], "winningPlan" : [ { + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -167,6 +176,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -188,6 +198,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -210,6 +221,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -220,6 +232,7 @@ "$eq" : 5 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -242,6 +255,7 @@ "x" ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -253,6 +267,7 @@ "$gt" : 3 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -278,6 +293,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -798,6 +814,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -823,6 +840,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -865,6 +883,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -890,6 +909,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -927,6 +947,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -952,6 +973,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -994,6 +1016,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1019,6 +1042,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1061,6 +1085,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1086,6 +1111,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1128,6 +1154,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" }, { @@ -1153,6 +1180,7 @@ "x" : [ ], "y" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1543,6 +1571,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1563,6 +1592,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ], @@ -1573,6 +1603,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1598,6 +1629,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1693,6 +1725,7 @@ "$lt" : 105 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1713,6 +1746,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1724,6 +1758,7 @@ "$gt" : -1 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1749,6 +1784,7 @@ "y" : [ ], "z" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1911,6 +1947,7 @@ "$lt" : 250 } }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "FETCH" }, { @@ -1931,6 +1968,7 @@ "multiKeyPaths" : { "x" : [ ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "IXSCAN" } ] @@ -1963,6 +2001,7 @@ } ] }, + "nss" : "test.distinct_command_multiplanning_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeRestricted/distinct_index_eligibility.md b/jstests/query_golden/expected_output/sbeRestricted/distinct_index_eligibility.md index 3e737044370..3e4c4758ae3 100644 --- a/jstests/query_golden/expected_output/sbeRestricted/distinct_index_eligibility.md +++ b/jstests/query_golden/expected_output/sbeRestricted/distinct_index_eligibility.md @@ -34,6 +34,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -61,6 +62,7 @@ Execution Engine: sbe ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] @@ -190,6 +192,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -348,6 +351,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -387,6 +391,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -443,6 +448,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -728,6 +734,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -932,6 +939,7 @@ Execution Engine: classic "$lt" : 3 } }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "COLLSCAN" } ] @@ -949,6 +957,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_index_eligibility_md", "stage" : "FETCH" }, { @@ -974,6 +983,7 @@ Execution Engine: classic "$_path" : [ ], "b" : [ ] }, + "nss" : "test.distinct_index_eligibility_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeRestricted/distinct_query_planner.md b/jstests/query_golden/expected_output/sbeRestricted/distinct_query_planner.md index 8c00ea6e05b..dcd30eeda12 100644 --- a/jstests/query_golden/expected_output/sbeRestricted/distinct_query_planner.md +++ b/jstests/query_golden/expected_output/sbeRestricted/distinct_query_planner.md @@ -209,6 +209,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] @@ -259,6 +260,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_query_planner_md", "stage" : "FETCH" }, { @@ -279,6 +281,7 @@ Execution Engine: sbe "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.distinct_query_planner_md", "stage" : "IXSCAN" } ] @@ -374,6 +377,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_query_planner_md", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden/expected_output/sbeRestricted/distinct_scan.md b/jstests/query_golden/expected_output/sbeRestricted/distinct_scan.md index ad3b82f1e38..8f7a02db2cc 100644 --- a/jstests/query_golden/expected_output/sbeRestricted/distinct_scan.md +++ b/jstests/query_golden/expected_output/sbeRestricted/distinct_scan.md @@ -10,6 +10,7 @@ "winningPlan" : [ { "direction" : "forward", + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -44,6 +45,7 @@ Execution Engine: sbe "filter" : { }, + "nss" : "test.distinct_scan_md", "stage" : "COLLSCAN" } ] @@ -688,6 +690,7 @@ Execution Engine: classic "rejectedPlans" : [ ], "winningPlan" : [ { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -708,6 +711,7 @@ Execution Engine: classic "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] @@ -746,6 +750,7 @@ Execution Engine: sbe "stage" : "GROUP" }, { + "nss" : "test.distinct_scan_md", "stage" : "FETCH" }, { @@ -766,6 +771,7 @@ Execution Engine: sbe "multiKeyPaths" : { "b" : [ ] }, + "nss" : "test.distinct_scan_md", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden/join_opt/basic_joins_md.js b/jstests/query_golden/join_opt/basic_joins_md.js index c7413bb7047..df90cb16682 100644 --- a/jstests/query_golden/join_opt/basic_joins_md.js +++ b/jstests/query_golden/join_opt/basic_joins_md.js @@ -56,27 +56,47 @@ function runBasicJoinTest(pipeline) { ); outputAggregationPlanAndResults(coll, pipeline, {}, true, false); const bottomUpLeftDeepResults = coll.aggregate(pipeline).toArray(); + assert( + _resultSetsEqualUnordered(noJoinOptResults, bottomUpLeftDeepResults), + "Results differ between no join opt and bottom-up left-deep join enumeration", + ); subSection("With bottom-up plan enumeration (right-deep)"); assert.commandWorked(db.adminCommand({setParameter: 1, internalJoinPlanTreeShape: "rightDeep"})); outputAggregationPlanAndResults(coll, pipeline, {}, true, false); const bottomUpRightDeepResults = coll.aggregate(pipeline).toArray(); + assert( + _resultSetsEqualUnordered(noJoinOptResults, bottomUpRightDeepResults), + "Results differ between no join opt and bottom-up right-deep join enumeration", + ); subSection("With bottom-up plan enumeration (zig-zag)"); assert.commandWorked(db.adminCommand({setParameter: 1, internalJoinPlanTreeShape: "zigZag"})); outputAggregationPlanAndResults(coll, pipeline, {}, true, false); const bottomUpZigZagResults = coll.aggregate(pipeline).toArray(); + assert( + _resultSetsEqualUnordered(noJoinOptResults, bottomUpZigZagResults), + "Results differ between no join opt and bottom-up zig-zag join enumeration", + ); subSection("With random order, seed 44, nested loop joins"); assert.commandWorked(db.adminCommand({setParameter: 1, internalJoinReorderMode: "random"})); assert.commandWorked(db.adminCommand({setParameter: 1, internalRandomJoinOrderSeed: 44})); outputAggregationPlanAndResults(coll, pipeline, {}, true, false); const seed44NLJResults = coll.aggregate(pipeline).toArray(); + assert( + _resultSetsEqualUnordered(noJoinOptResults, seed44NLJResults), + "Results differ between no join opt and seed 44 NLJ", + ); subSection("With random order, seed 44, hash join enabled"); assert.commandWorked(db.adminCommand({setParameter: 1, internalRandomJoinReorderDefaultToHashJoin: true})); outputAggregationPlanAndResults(coll, pipeline, {}, true, false); const seed44HJResults = coll.aggregate(pipeline).toArray(); + assert( + _resultSetsEqualUnordered(noJoinOptResults, seed44HJResults), + "Results differ between no join opt and seed 44 HJ", + ); assert.commandWorked(db.adminCommand({setParameter: 1, internalRandomJoinReorderDefaultToHashJoin: false})); @@ -85,41 +105,33 @@ function runBasicJoinTest(pipeline) { assert.commandWorked(db.adminCommand({setParameter: 1, internalRandomJoinOrderSeed: 420})); outputAggregationPlanAndResults(coll, pipeline, {}, true, false); const seed420NLJResults = coll.aggregate(pipeline).toArray(); + assert( + _resultSetsEqualUnordered(noJoinOptResults, seed420NLJResults), + "Results differ between no join opt and seed 420 NLJ", + ); subSection("With random order, seed 420, hash join enabled"); assert.commandWorked(db.adminCommand({setParameter: 1, internalRandomJoinReorderDefaultToHashJoin: true})); outputAggregationPlanAndResults(coll, pipeline, {}, true, false); const seed420HJResults = coll.aggregate(pipeline).toArray(); - - // Validate that all execution modes return the same results. - assert( - _resultSetsEqualUnordered(noJoinOptResults, bottomUpLeftDeepResults), - "Results differ between no join opt and bottom-up left-deep join enumeration", - ); - assert( - _resultSetsEqualUnordered(noJoinOptResults, bottomUpRightDeepResults), - "Results differ between no join opt and bottom-up right-deep join enumeration", - ); - assert( - _resultSetsEqualUnordered(noJoinOptResults, bottomUpZigZagResults), - "Results differ between no join opt and bottom-up zig-zag join enumeration", - ); - assert( - _resultSetsEqualUnordered(noJoinOptResults, seed44NLJResults), - "Results differ between no join opt and seed 44 NLJ", - ); - assert( - _resultSetsEqualUnordered(noJoinOptResults, seed44HJResults), - "Results differ between no join opt and seed 44 HJ", - ); - assert( - _resultSetsEqualUnordered(noJoinOptResults, seed420NLJResults), - "Results differ between no join opt and seed 420 NLJ", - ); assert( _resultSetsEqualUnordered(noJoinOptResults, seed420HJResults), "Results differ between no join opt and seed 420 HJ", ); + + assert.commandWorked(db.adminCommand({setParameter: 1, internalRandomJoinReorderDefaultToHashJoin: false})); + + foreignColl1.createIndex({a: 1}); + foreignColl2.createIndex({b: 1}); + subSection("With fixed order, index join"); + outputAggregationPlanAndResults(coll, pipeline, {}, true, false); + const seedINJResults = coll.aggregate(pipeline).toArray(); + foreignColl1.dropIndex({a: 1}); + foreignColl2.dropIndex({b: 1}); + assert( + _resultSetsEqualUnordered(noJoinOptResults, seedINJResults), + "Results differ between no join opt and INJ", + ); } finally { // Reset flags. assert.commandWorked(db.adminCommand({setParameter: 1, internalEnableJoinOptimization: false})); diff --git a/jstests/query_golden/large_in_with_indexes_md.js b/jstests/query_golden/large_in_with_indexes_md.js index 364d0aad429..a0d626582ba 100644 --- a/jstests/query_golden/large_in_with_indexes_md.js +++ b/jstests/query_golden/large_in_with_indexes_md.js @@ -1,6 +1,6 @@ // Tests that a query with $in filter over a large array chooses the optimal index. import {code, codeOneLine, section, subSection} from "jstests/libs/pretty_md.js"; -import {formatExplainRoot} from "jstests/libs/query/analyze_plan.js"; +import {normalizePlan, getWinningPlanFromExplain} from "jstests/libs/query/analyze_plan.js"; const coll = db.large_in_with_indexes; coll.drop(); @@ -33,7 +33,7 @@ const explain = coll.find(filter).sort(sort).explain("executionStats"); subSection("Expected plan"); print("Note: expecting an IXSCAN on _id_1_rd_1_ard_1"); -code(tojson(formatExplainRoot(explain))); +code(tojson(normalizePlan(getWinningPlanFromExplain(explain.queryPlanner)))); subSection("Output"); const output = coll.find(filter).sort(sort).toArray(); diff --git a/jstests/query_golden_sharding/expected_output/distinct_chunk_skipping.md b/jstests/query_golden_sharding/expected_output/distinct_chunk_skipping.md index fa6fecf8b0d..9930d59d06c 100644 --- a/jstests/query_golden_sharding/expected_output/distinct_chunk_skipping.md +++ b/jstests/query_golden_sharding/expected_output/distinct_chunk_skipping.md @@ -740,6 +740,7 @@ "$gte" : "shard0" } }, + "nss" : "test.distinct_chunk_skipping", "stage" : "FETCH" }, { @@ -760,6 +761,7 @@ "multiKeyPaths" : { "c" : [ ] }, + "nss" : "test.distinct_chunk_skipping", "stage" : "IXSCAN" } ] @@ -863,6 +865,7 @@ "$gte" : "shard0" } }, + "nss" : "test.distinct_chunk_skipping", "stage" : "FETCH" }, { @@ -883,6 +886,7 @@ "multiKeyPaths" : { "c" : [ ] }, + "nss" : "test.distinct_chunk_skipping", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeDisabled/distinct_scan_multi_chunk.md b/jstests/query_golden_sharding/expected_output/sbeDisabled/distinct_scan_multi_chunk.md index 580cd87c1b1..3668e51990d 100644 --- a/jstests/query_golden_sharding/expected_output/sbeDisabled/distinct_scan_multi_chunk.md +++ b/jstests/query_golden_sharding/expected_output/sbeDisabled/distinct_scan_multi_chunk.md @@ -198,6 +198,7 @@ "$eq" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -215,6 +216,7 @@ "$eq" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -408,6 +410,7 @@ "$gte" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -425,6 +428,7 @@ "$gte" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -522,6 +526,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -542,6 +547,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -675,6 +681,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -698,6 +705,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -743,6 +751,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -766,6 +775,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -1890,6 +1900,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -1913,6 +1924,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -1951,6 +1963,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -1975,6 +1988,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -1998,6 +2012,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2036,6 +2051,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2364,6 +2380,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -2387,6 +2404,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2425,6 +2443,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2452,6 +2471,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -2475,6 +2495,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2513,6 +2534,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2661,6 +2683,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -2684,6 +2707,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2723,6 +2747,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2751,6 +2776,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -2774,6 +2800,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2813,6 +2840,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3389,6 +3417,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3432,6 +3461,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3601,6 +3631,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3645,6 +3676,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3814,6 +3846,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3857,6 +3890,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -4026,6 +4060,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -4070,6 +4105,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -6053,6 +6089,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6094,6 +6131,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6210,6 +6248,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6251,6 +6290,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6368,6 +6408,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6409,6 +6450,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6525,6 +6567,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6566,6 +6609,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -8802,6 +8846,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -8825,6 +8870,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -8907,6 +8953,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -8930,6 +8977,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9111,6 +9159,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9134,6 +9183,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9216,6 +9266,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9239,6 +9290,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9749,6 +9801,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9772,6 +9825,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9835,6 +9889,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9858,6 +9913,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10014,6 +10070,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10037,6 +10094,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10100,6 +10158,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10123,6 +10182,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10310,6 +10370,7 @@ "$eq" : null } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10337,6 +10398,7 @@ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10348,6 +10410,7 @@ "$eq" : null } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10368,6 +10431,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10393,6 +10457,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10423,6 +10488,7 @@ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10432,6 +10498,7 @@ "stage" : "SHARDING_FILTER" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10454,6 +10521,7 @@ "notShardKey" ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeDisabled/group_targeting.md b/jstests/query_golden_sharding/expected_output/sbeDisabled/group_targeting.md index d6125b19c64..86ba8351237 100644 --- a/jstests/query_golden_sharding/expected_output/sbeDisabled/group_targeting.md +++ b/jstests/query_golden_sharding/expected_output/sbeDisabled/group_targeting.md @@ -381,6 +381,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -413,6 +414,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -503,6 +505,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -532,6 +535,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -614,6 +618,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -646,6 +651,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -756,6 +762,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -811,6 +818,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -954,6 +962,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -986,6 +995,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1075,6 +1085,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1110,6 +1121,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1226,6 +1238,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1270,6 +1283,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1413,6 +1427,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1446,6 +1461,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1545,6 +1561,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1583,6 +1600,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1696,6 +1714,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1734,6 +1753,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1848,6 +1868,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1890,6 +1911,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1995,6 +2017,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2023,6 +2046,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2107,6 +2131,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2135,6 +2160,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2222,6 +2248,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2250,6 +2277,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2341,6 +2369,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2374,6 +2403,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2457,6 +2487,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2478,6 +2509,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2705,6 +2737,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2733,6 +2766,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2832,6 +2866,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2871,6 +2906,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2983,6 +3019,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3018,6 +3055,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3117,6 +3155,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3158,6 +3197,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3264,6 +3304,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3300,6 +3341,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3421,6 +3463,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3456,6 +3499,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3577,6 +3621,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3618,6 +3663,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3725,6 +3771,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3757,6 +3804,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3866,6 +3914,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3903,6 +3952,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -4012,6 +4062,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -4052,6 +4103,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -4180,6 +4232,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -4235,6 +4288,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeDisabled/sort_group_targeting.md b/jstests/query_golden_sharding/expected_output/sbeDisabled/sort_group_targeting.md index 5cac86f50f1..ecb23cad8f7 100644 --- a/jstests/query_golden_sharding/expected_output/sbeDisabled/sort_group_targeting.md +++ b/jstests/query_golden_sharding/expected_output/sbeDisabled/sort_group_targeting.md @@ -481,6 +481,7 @@ } }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -504,6 +505,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -540,6 +542,7 @@ } }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -563,6 +566,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -665,6 +669,7 @@ "stage" : "SORT_KEY_GENERATOR" }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -688,6 +693,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -706,6 +712,7 @@ "stage" : "SORT_KEY_GENERATOR" }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -729,6 +736,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -821,6 +829,7 @@ }, { "direction" : "forward", + "nss" : "test.sort_group_targeting", "stage" : "COLLSCAN" } ] @@ -851,6 +860,7 @@ }, { "direction" : "forward", + "nss" : "test.sort_group_targeting", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeFull/distinct_scan_multi_chunk.md b/jstests/query_golden_sharding/expected_output/sbeFull/distinct_scan_multi_chunk.md index 5afec4c69f7..1e234d7e175 100644 --- a/jstests/query_golden_sharding/expected_output/sbeFull/distinct_scan_multi_chunk.md +++ b/jstests/query_golden_sharding/expected_output/sbeFull/distinct_scan_multi_chunk.md @@ -198,6 +198,7 @@ "$eq" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -215,6 +216,7 @@ "$eq" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -408,6 +410,7 @@ "$gte" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -425,6 +428,7 @@ "$gte" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -522,6 +526,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -542,6 +547,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -675,6 +681,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -698,6 +705,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -743,6 +751,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -766,6 +775,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -1952,6 +1962,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2031,6 +2042,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2414,6 +2426,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2493,6 +2506,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2694,6 +2708,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2775,6 +2790,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3341,6 +3357,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3384,6 +3401,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3553,6 +3571,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3597,6 +3616,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3766,6 +3786,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3809,6 +3830,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3978,6 +4000,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -4022,6 +4045,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -6005,6 +6029,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6046,6 +6071,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6162,6 +6188,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6203,6 +6230,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6320,6 +6348,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6361,6 +6390,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6477,6 +6507,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6518,6 +6549,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -8754,6 +8786,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -8777,6 +8810,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -8859,6 +8893,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -8882,6 +8917,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9063,6 +9099,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9086,6 +9123,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9168,6 +9206,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9191,6 +9230,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9701,6 +9741,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9724,6 +9765,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9787,6 +9829,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9810,6 +9853,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9966,6 +10010,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9989,6 +10034,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10052,6 +10098,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10075,6 +10122,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10300,6 +10348,7 @@ "$eq" : null } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10320,6 +10369,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10384,6 +10434,7 @@ "stage" : "SHARDING_FILTER" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10406,6 +10457,7 @@ "notShardKey" ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeFull/group_targeting.md b/jstests/query_golden_sharding/expected_output/sbeFull/group_targeting.md index 888fa998f0b..1dd2c3166e8 100644 --- a/jstests/query_golden_sharding/expected_output/sbeFull/group_targeting.md +++ b/jstests/query_golden_sharding/expected_output/sbeFull/group_targeting.md @@ -378,6 +378,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -396,6 +397,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -479,6 +481,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -504,6 +507,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -575,6 +579,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -593,6 +598,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -698,6 +704,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -735,6 +742,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -858,6 +866,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -883,6 +892,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -964,6 +974,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1002,6 +1013,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1121,6 +1133,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1168,6 +1181,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1314,6 +1328,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1350,6 +1365,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1448,6 +1464,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1469,6 +1486,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1565,6 +1583,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1586,6 +1605,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1684,6 +1704,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1705,6 +1726,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1786,6 +1808,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1804,6 +1827,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1885,6 +1909,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1910,6 +1935,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1994,6 +2020,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2019,6 +2046,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2113,6 +2141,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2144,6 +2173,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2219,6 +2249,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2237,6 +2268,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2454,6 +2486,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2472,6 +2505,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2580,6 +2614,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2617,6 +2652,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2706,6 +2742,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2724,6 +2761,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2806,6 +2844,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2824,6 +2863,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2916,6 +2956,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2934,6 +2975,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3037,6 +3079,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3064,6 +3107,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3177,6 +3221,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3211,6 +3256,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3303,6 +3349,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3321,6 +3368,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3424,6 +3472,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3452,6 +3501,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3546,6 +3596,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3567,6 +3618,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3695,6 +3747,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3735,6 +3788,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeFull/sort_group_targeting.md b/jstests/query_golden_sharding/expected_output/sbeFull/sort_group_targeting.md index a1d6e546636..55d385729dd 100644 --- a/jstests/query_golden_sharding/expected_output/sbeFull/sort_group_targeting.md +++ b/jstests/query_golden_sharding/expected_output/sbeFull/sort_group_targeting.md @@ -481,6 +481,7 @@ } }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -504,6 +505,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -540,6 +542,7 @@ } }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -563,6 +566,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -665,6 +669,7 @@ "stage" : "SORT_KEY_GENERATOR" }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -688,6 +693,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -706,6 +712,7 @@ "stage" : "SORT_KEY_GENERATOR" }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -729,6 +736,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -824,6 +832,7 @@ "filter" : { }, + "nss" : "test.sort_group_targeting", "stage" : "COLLSCAN" } ] @@ -857,6 +866,7 @@ "filter" : { }, + "nss" : "test.sort_group_targeting", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeRestricted/distinct_scan_multi_chunk.md b/jstests/query_golden_sharding/expected_output/sbeRestricted/distinct_scan_multi_chunk.md index 5afec4c69f7..406e6739af3 100644 --- a/jstests/query_golden_sharding/expected_output/sbeRestricted/distinct_scan_multi_chunk.md +++ b/jstests/query_golden_sharding/expected_output/sbeRestricted/distinct_scan_multi_chunk.md @@ -198,6 +198,7 @@ "$eq" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -215,6 +216,7 @@ "$eq" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -408,6 +410,7 @@ "$gte" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -425,6 +428,7 @@ "$gte" : "1notShardKey_chunk1_s0_1" } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -522,6 +526,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -542,6 +547,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -675,6 +681,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -698,6 +705,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -743,6 +751,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -766,6 +775,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -1952,6 +1962,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2031,6 +2042,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2414,6 +2426,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2493,6 +2506,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2694,6 +2708,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -2775,6 +2790,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3341,6 +3357,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3384,6 +3401,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3553,6 +3571,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3597,6 +3616,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3766,6 +3786,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3809,6 +3830,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -3978,6 +4000,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -4022,6 +4045,7 @@ "notShardKey" : [ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -6005,6 +6029,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6046,6 +6071,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6162,6 +6188,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6203,6 +6230,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6320,6 +6348,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6361,6 +6390,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6477,6 +6507,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -6518,6 +6549,7 @@ }, { "direction" : "forward", + "nss" : "test.distinct_scan_multi_chunk", "stage" : "COLLSCAN" } ] @@ -8754,6 +8786,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -8777,6 +8810,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -8859,6 +8893,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -8882,6 +8917,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9063,6 +9099,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9086,6 +9123,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9168,6 +9206,7 @@ } }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9191,6 +9230,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9701,6 +9741,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9724,6 +9765,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9787,6 +9829,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9810,6 +9853,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -9966,6 +10010,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -9989,6 +10034,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10052,6 +10098,7 @@ "type" : "simple" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10075,6 +10122,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10262,6 +10310,7 @@ "$eq" : null } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10289,6 +10338,7 @@ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10300,6 +10350,7 @@ "$eq" : null } }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10320,6 +10371,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10345,6 +10397,7 @@ "rejectedPlans" : [ [ { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10375,6 +10428,7 @@ ], "shardKey" : [ ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] @@ -10384,6 +10438,7 @@ "stage" : "SHARDING_FILTER" }, { + "nss" : "test.distinct_scan_multi_chunk", "stage" : "FETCH" }, { @@ -10406,6 +10461,7 @@ "notShardKey" ] }, + "nss" : "test.distinct_scan_multi_chunk", "stage" : "IXSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeRestricted/group_targeting.md b/jstests/query_golden_sharding/expected_output/sbeRestricted/group_targeting.md index 5774d8e845a..1dff4b6259c 100644 --- a/jstests/query_golden_sharding/expected_output/sbeRestricted/group_targeting.md +++ b/jstests/query_golden_sharding/expected_output/sbeRestricted/group_targeting.md @@ -378,6 +378,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -396,6 +397,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -479,6 +481,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -504,6 +507,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -575,6 +579,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -593,6 +598,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -690,6 +696,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -726,6 +733,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -856,6 +864,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -881,6 +890,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -959,6 +969,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -994,6 +1005,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1110,6 +1122,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1154,6 +1167,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1297,6 +1311,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1330,6 +1345,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1428,6 +1444,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1449,6 +1466,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1545,6 +1563,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1566,6 +1585,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1664,6 +1684,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1685,6 +1706,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1766,6 +1788,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1784,6 +1807,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1865,6 +1889,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1890,6 +1915,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1974,6 +2000,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -1999,6 +2026,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2083,6 +2111,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2116,6 +2145,7 @@ }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2203,6 +2233,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2221,6 +2252,7 @@ "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2438,6 +2470,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2456,6 +2489,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2548,6 +2582,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2587,6 +2622,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting", "stage" : "COLLSCAN" } ] @@ -2694,6 +2730,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2712,6 +2749,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2794,6 +2832,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2812,6 +2851,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2904,6 +2944,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -2922,6 +2963,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3025,6 +3067,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3052,6 +3095,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3165,6 +3209,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3199,6 +3244,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3291,6 +3337,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3309,6 +3356,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3412,6 +3460,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3440,6 +3489,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3534,6 +3584,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3555,6 +3606,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. "filter" : { }, + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3666,6 +3718,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] @@ -3721,6 +3774,7 @@ Note: If we have duplicate _ids in the output, that signals a bug here. }, { "direction" : "forward", + "nss" : "test.group_targeting_compound", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sbeRestricted/sort_group_targeting.md b/jstests/query_golden_sharding/expected_output/sbeRestricted/sort_group_targeting.md index 5cac86f50f1..ecb23cad8f7 100644 --- a/jstests/query_golden_sharding/expected_output/sbeRestricted/sort_group_targeting.md +++ b/jstests/query_golden_sharding/expected_output/sbeRestricted/sort_group_targeting.md @@ -481,6 +481,7 @@ } }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -504,6 +505,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -540,6 +542,7 @@ } }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -563,6 +566,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -665,6 +669,7 @@ "stage" : "SORT_KEY_GENERATOR" }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -688,6 +693,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -706,6 +712,7 @@ "stage" : "SORT_KEY_GENERATOR" }, { + "nss" : "test.sort_group_targeting", "stage" : "FETCH" }, { @@ -729,6 +736,7 @@ "multiKeyPaths" : { "shardKey" : [ ] }, + "nss" : "test.sort_group_targeting", "stage" : "IXSCAN" } ] @@ -821,6 +829,7 @@ }, { "direction" : "forward", + "nss" : "test.sort_group_targeting", "stage" : "COLLSCAN" } ] @@ -851,6 +860,7 @@ }, { "direction" : "forward", + "nss" : "test.sort_group_targeting", "stage" : "COLLSCAN" } ] diff --git a/jstests/query_golden_sharding/expected_output/sharded_find_with_collation.md b/jstests/query_golden_sharding/expected_output/sharded_find_with_collation.md index cd75519f2c3..e1d965df741 100644 --- a/jstests/query_golden_sharding/expected_output/sharded_find_with_collation.md +++ b/jstests/query_golden_sharding/expected_output/sharded_find_with_collation.md @@ -24,8 +24,10 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -60,10 +62,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -98,10 +102,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -136,10 +142,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -174,10 +182,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -212,10 +222,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -250,10 +262,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -301,8 +315,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -336,8 +352,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -371,8 +389,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -406,8 +426,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -441,8 +463,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -476,8 +500,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -502,6 +528,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -525,6 +552,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -548,6 +576,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -580,6 +609,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -616,10 +646,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -654,10 +686,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -692,10 +726,12 @@ "multiKeyPaths" : { "a" : [ ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -717,6 +753,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -740,6 +777,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -763,6 +801,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -795,6 +834,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -828,8 +868,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -863,8 +905,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -898,8 +942,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -924,6 +970,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -947,6 +994,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -970,6 +1018,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1002,6 +1051,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1025,6 +1075,7 @@ "$gt" : { "$minKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1048,6 +1099,7 @@ "$lt" : { "$maxKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1080,6 +1132,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1129,10 +1182,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1164,10 +1219,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1199,10 +1256,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1234,10 +1293,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1269,10 +1330,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1304,10 +1367,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1330,6 +1395,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1353,6 +1419,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1376,6 +1443,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1408,6 +1476,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1431,6 +1500,7 @@ "$gt" : { "$minKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1454,6 +1524,7 @@ "$lt" : { "$maxKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1486,6 +1557,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1509,6 +1581,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1532,6 +1605,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1555,6 +1629,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1587,6 +1662,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1620,10 +1696,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1655,10 +1733,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1690,10 +1770,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1730,8 +1812,10 @@ "keyPattern" : { "a" : "hashed" }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -1753,6 +1837,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1776,6 +1861,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1808,6 +1894,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1831,6 +1918,7 @@ "$gt" : { "$minKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1854,6 +1942,7 @@ "$lt" : { "$maxKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1886,6 +1975,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -1935,8 +2025,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -1970,8 +2062,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2005,8 +2099,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2040,8 +2136,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2075,8 +2173,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2110,8 +2210,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2136,6 +2238,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2159,6 +2262,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2182,6 +2286,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2214,6 +2319,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2237,6 +2343,7 @@ "$gt" : { "$minKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2260,6 +2367,7 @@ "$lt" : { "$maxKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2292,6 +2400,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2315,6 +2424,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2338,6 +2448,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2361,6 +2472,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2393,6 +2505,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2426,8 +2539,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2461,8 +2576,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2496,8 +2613,10 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" }, "stage" : "SHARDING_FILTER" @@ -2522,6 +2641,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2545,6 +2665,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2568,6 +2689,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2600,6 +2722,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2623,6 +2746,7 @@ "$gt" : { "$minKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2646,6 +2770,7 @@ "$lt" : { "$maxKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2678,6 +2803,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2727,10 +2853,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -2762,10 +2890,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -2797,10 +2927,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -2832,10 +2964,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -2867,10 +3001,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -2902,10 +3038,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -2928,6 +3066,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2951,6 +3090,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -2974,6 +3114,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3006,6 +3147,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3029,6 +3171,7 @@ "$gt" : { "$minKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3052,6 +3195,7 @@ "$lt" : { "$maxKey" : 1 } } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3084,6 +3228,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3107,6 +3252,7 @@ "$eq" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3130,6 +3276,7 @@ "$lte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3153,6 +3300,7 @@ "$gte" : "a" } }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3185,6 +3333,7 @@ } ] }, + "nss" : "test.sharded_find_with_collation", "stage" : "COLLSCAN" }, "stage" : "SHARDING_FILTER" @@ -3218,10 +3367,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -3253,10 +3404,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` @@ -3288,10 +3441,12 @@ "keyPattern" : { "_id" : 1 }, + "nss" : "test.sharded_find_with_collation", "stage" : "IXSCAN" }, "stage" : "SHARDING_FILTER" }, + "nss" : "test.sharded_find_with_collation", "stage" : "FETCH" } ``` diff --git a/src/mongo/db/collection_index_usage_tracker.cpp b/src/mongo/db/collection_index_usage_tracker.cpp index 79a46dcb4de..4f90ede179c 100644 --- a/src/mongo/db/collection_index_usage_tracker.cpp +++ b/src/mongo/db/collection_index_usage_tracker.cpp @@ -53,12 +53,17 @@ CollectionIndexUsageTracker::CollectionIndexUsageTracker( } void CollectionIndexUsageTracker::recordIndexAccess(StringData indexName) const { - invariant(!indexName.empty()); + tassert(11122205, + "CollectionIndexUsageTracker::recordIndexAccess invoked with an empty indexname", + !indexName.empty()); auto it = _indexUsageStatsMap.find(indexName); // The index is guaranteed to be tracked - invariant(it != _indexUsageStatsMap.end()); + tassert(11122206, + str::stream() << "Index '" << indexName + << "' is not registered in CollectionIndexUsageTracker", + it != _indexUsageStatsMap.end()); _aggregatedIndexUsageTracker->onAccess(it->second->features); @@ -78,18 +83,26 @@ void CollectionIndexUsageTracker::recordCollectionScansNonTailable( void CollectionIndexUsageTracker::registerIndex(StringData indexName, const BSONObj& indexKey, const IndexFeatures& features) { - invariant(!indexName.empty()); + tassert(11122207, + "CollectionIndexUsageTracker::registerIndex invoked with an empty indexname", + !indexName.empty()); // Create the map entry. auto inserted = _indexUsageStatsMap.try_emplace( indexName, make_intrusive(_clockSource->now(), indexKey, features)); - invariant(inserted.second); + tassert(11122208, + str::stream() + << "CollectionIndexUsageTracker::registerIndex has already been invoked for index '" + << indexName << "'", + inserted.second); _aggregatedIndexUsageTracker->onRegister(inserted.first->second->features); } void CollectionIndexUsageTracker::unregisterIndex(StringData indexName) { - invariant(!indexName.empty()); + tassert(11122209, + "CollectionIndexUsageTracker::unregisterIndex invoked with an empty indexname", + !indexName.empty()); auto it = _indexUsageStatsMap.find(indexName); // Only finished/ready indexes are tracked and this function may be called for an unfinished diff --git a/src/mongo/db/query/compiler/optimizer/join/reorder_joins.cpp b/src/mongo/db/query/compiler/optimizer/join/reorder_joins.cpp index af575732298..20385bbedab 100644 --- a/src/mongo/db/query/compiler/optimizer/join/reorder_joins.cpp +++ b/src/mongo/db/query/compiler/optimizer/join/reorder_joins.cpp @@ -403,8 +403,6 @@ ReorderedJoinSolution constructSolutionWithRandomOrder( std::make_unique(currentNode.collectionName, std::move(indexEntry.value())), currentNode.collectionName); - // TODO SERVER-111222: Write an end-to-end test exercising this codepath, once we - // can lower INLJ nodes to SBE. if (auto matchExpr = currentNode.accessPath->getPrimaryMatchExpression(); matchExpr != nullptr && !matchExpr->isTriviallyTrue()) { rhs->filter = matchExpr->clone(); diff --git a/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.cpp b/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.cpp index 5bac02b3296..f4cfb19ca2d 100644 --- a/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.cpp +++ b/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.cpp @@ -35,10 +35,8 @@ #include "mongo/bson/util/builder_fwd.h" #include "mongo/db/exec/document_value/value.h" #include "mongo/db/field_ref.h" -#include "mongo/db/index/multikey_paths.h" #include "mongo/db/index_names.h" #include "mongo/db/keypattern.h" -#include "mongo/db/matcher/expression_algo.h" #include "mongo/db/matcher/expression_geo.h" #include "mongo/db/namespace_string.h" #include "mongo/db/query/collation/collation_index_key.h" @@ -125,11 +123,45 @@ void getAllSecondaryNamespacesHelper(const QuerySolutionNode* qsn, return; } - if (auto eqLookupNode = dynamic_cast(qsn)) { - NamespaceString nss(eqLookupNode->foreignCollection); - if (nss != mainNss) { - secondaryNssSet.emplace(std::move(nss)); - } + if (auto node = dynamic_cast(qsn); + node && node->foreignCollection != mainNss) { + secondaryNssSet.emplace(node->foreignCollection); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); + } + + if (auto node = dynamic_cast(qsn); node && node->nss != mainNss) { + secondaryNssSet.emplace(node->nss); } for (auto&& child : qsn->children) { @@ -660,6 +692,8 @@ std::unique_ptr MergeSortNode::clone() const { void FetchNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "FETCH\n"; + addIndent(ss, indent + 1); + *ss << "ns = " << toStringForLogging(nss) << '\n'; if (nullptr != filter) { addIndent(ss, indent + 1); StringBuilder sb; @@ -695,6 +729,8 @@ void IndexScanNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "IXSCAN\n"; addIndent(ss, indent + 1); + *ss << "ns = " << toStringForLogging(nss) << '\n'; + addIndent(ss, indent + 1); *ss << "indexName = " << index.identifier.catalogName << '\n'; addIndent(ss, indent + 1); *ss << "keyPattern = " << index.keyPattern << '\n'; diff --git a/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.h b/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.h index 38148c41c4f..507ea649235 100644 --- a/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.h +++ b/src/mongo/db/query/compiler/physical_model/query_solution/query_solution.h @@ -572,8 +572,6 @@ struct CollectionScanNode : public QuerySolutionNodeWithSortSet { eligibleForPlanCache = false; } - IndexBounds getIndexBounds() const; - std::unique_ptr clone() const final; // Name of the namespace. diff --git a/src/mongo/db/query/compiler/physical_model/query_solution/stage_types.cpp b/src/mongo/db/query/compiler/physical_model/query_solution/stage_types.cpp index ca67c15b791..ea3421349d4 100644 --- a/src/mongo/db/query/compiler/physical_model/query_solution/stage_types.cpp +++ b/src/mongo/db/query/compiler/physical_model/query_solution/stage_types.cpp @@ -147,6 +147,8 @@ StringData nodeStageTypeToString(const QuerySolutionNode* node) { return "NESTED_LOOP_JOIN_EMBEDDING"_sd; case STAGE_INDEXED_NESTED_LOOP_JOIN_EMBEDDING_NODE: return "INDEXED_NESTED_LOOP_JOIN_EMBEDDING"_sd; + case STAGE_INDEX_PROBE_NODE: + return "INDEX_PROBE_NODE"_sd; default: return "UNKNOWN"_sd; } diff --git a/src/mongo/db/query/plan_explainer_impl.cpp b/src/mongo/db/query/plan_explainer_impl.cpp index 0aab062d1c8..81a8b931786 100644 --- a/src/mongo/db/query/plan_explainer_impl.cpp +++ b/src/mongo/db/query/plan_explainer_impl.cpp @@ -330,6 +330,11 @@ void statsToBSON(const stage_builder::PlanStageToQsnMap& planStageQsnMap, } } else if (STAGE_COLLSCAN == stats.stageType) { CollectionScanStats* spec = static_cast(stats.specific.get()); + if (auto qsnNode = dynamic_cast(querySolutionNode); qsnNode) { + bob->append( + "nss", + NamespaceStringUtil::serialize(qsnNode->nss, SerializationContext::stateDefault())); + } bob->append("direction", spec->direction > 0 ? "forward" : "backward"); if (spec->minRecord) { spec->minRecord->appendToBSONAs(bob, "minRecord"); @@ -354,6 +359,11 @@ void statsToBSON(const stage_builder::PlanStageToQsnMap& planStageQsnMap, bob->appendNumber("keysExamined", static_cast(spec->keysExamined)); } + if (auto qsnNode = dynamic_cast(querySolutionNode); qsnNode) { + bob->append( + "nss", + NamespaceStringUtil::serialize(qsnNode->nss, SerializationContext::stateDefault())); + } bob->append("keyPattern", spec->keyPattern); bob->append("indexName", spec->indexName); if (!spec->collation.isEmpty()) { @@ -424,6 +434,11 @@ void statsToBSON(const stage_builder::PlanStageToQsnMap& planStageQsnMap, } } else if (STAGE_FETCH == stats.stageType) { FetchStats* spec = static_cast(stats.specific.get()); + if (auto qsnNode = dynamic_cast(querySolutionNode); qsnNode) { + bob->append( + "nss", + NamespaceStringUtil::serialize(qsnNode->nss, SerializationContext::stateDefault())); + } if (verbosity >= ExplainOptions::Verbosity::kExecStats) { bob->appendNumber("docsExamined", static_cast(spec->docsExamined)); bob->appendNumber("alreadyHasObj", static_cast(spec->alreadyHasObj)); @@ -431,6 +446,16 @@ void statsToBSON(const stage_builder::PlanStageToQsnMap& planStageQsnMap, } else if (STAGE_GEO_NEAR_2D == stats.stageType || STAGE_GEO_NEAR_2DSPHERE == stats.stageType) { NearStats* spec = static_cast(stats.specific.get()); + if (auto qsnNode = dynamic_cast(querySolutionNode); qsnNode) { + bob->append( + "nss", + NamespaceStringUtil::serialize(qsnNode->nss, SerializationContext::stateDefault())); + } else if (auto qsnNode = dynamic_cast(querySolutionNode); + qsnNode) { + bob->append( + "nss", + NamespaceStringUtil::serialize(qsnNode->nss, SerializationContext::stateDefault())); + } bob->append("keyPattern", spec->keyPattern); bob->append("indexName", spec->indexName); bob->append("indexVersion", spec->indexVersion); @@ -467,6 +492,11 @@ void statsToBSON(const stage_builder::PlanStageToQsnMap& planStageQsnMap, } else if (STAGE_IXSCAN == stats.stageType) { IndexScanStats* spec = static_cast(stats.specific.get()); + if (auto qsnNode = dynamic_cast(querySolutionNode); qsnNode) { + bob->append( + "nss", + NamespaceStringUtil::serialize(qsnNode->nss, SerializationContext::stateDefault())); + } bob->append("keyPattern", spec->keyPattern); bob->append("indexName", spec->indexName); if (!spec->collation.isEmpty()) { @@ -584,6 +614,11 @@ void statsToBSON(const stage_builder::PlanStageToQsnMap& planStageQsnMap, } else if (STAGE_TEXT_MATCH == stats.stageType) { TextMatchStats* spec = static_cast(stats.specific.get()); + if (auto qsnNode = dynamic_cast(querySolutionNode); qsnNode) { + bob->append( + "nss", + NamespaceStringUtil::serialize(qsnNode->nss, SerializationContext::stateDefault())); + } bob->append("indexPrefix", spec->indexPrefix); bob->append("indexName", spec->indexName); bob->append("parsedTextQuery", spec->parsedTextQuery); diff --git a/src/mongo/db/query/plan_explainer_sbe.cpp b/src/mongo/db/query/plan_explainer_sbe.cpp index 8fb110bd7dc..f0851575270 100644 --- a/src/mongo/db/query/plan_explainer_sbe.cpp +++ b/src/mongo/db/query/plan_explainer_sbe.cpp @@ -287,6 +287,9 @@ void statsToBSON(const QuerySolutionNode* node, switch (node->getType()) { case STAGE_COLLSCAN: { auto csn = static_cast(node); + bob->append( + "nss", + NamespaceStringUtil::serialize(csn->nss, SerializationContext::stateDefault())); bob->append("direction", csn->direction > 0 ? "forward" : "backward"); if (csn->minRecord) { csn->minRecord->appendToBSONAs(bob, "minRecord"); @@ -298,7 +301,9 @@ void statsToBSON(const QuerySolutionNode* node, } case STAGE_COUNT_SCAN: { auto csn = static_cast(node); - + bob->append( + "nss", + NamespaceStringUtil::serialize(csn->nss, SerializationContext::stateDefault())); bob->append("keyPattern", csn->index.keyPattern); bob->append("indexName", csn->index.identifier.catalogName); auto collation = @@ -326,6 +331,9 @@ void statsToBSON(const QuerySolutionNode* node, } case STAGE_GEO_NEAR_2D: { auto geo2d = static_cast(node); + bob->append( + "nss", + NamespaceStringUtil::serialize(geo2d->nss, SerializationContext::stateDefault())); bob->append("keyPattern", geo2d->index.keyPattern); bob->append("indexName", geo2d->index.identifier.catalogName); bob->append("indexVersion", geo2d->index.version); @@ -333,6 +341,9 @@ void statsToBSON(const QuerySolutionNode* node, } case STAGE_GEO_NEAR_2DSPHERE: { auto geo2dsphere = static_cast(node); + bob->append("nss", + NamespaceStringUtil::serialize(geo2dsphere->nss, + SerializationContext::stateDefault())); bob->append("keyPattern", geo2dsphere->index.keyPattern); bob->append("indexName", geo2dsphere->index.identifier.catalogName); bob->append("indexVersion", geo2dsphere->index.version); @@ -340,7 +351,9 @@ void statsToBSON(const QuerySolutionNode* node, } case STAGE_IXSCAN: { auto ixn = static_cast(node); - + bob->append( + "nss", + NamespaceStringUtil::serialize(ixn->nss, SerializationContext::stateDefault())); bob->append("keyPattern", ixn->index.keyPattern); bob->append("indexName", ixn->index.identifier.catalogName); auto collation = @@ -404,7 +417,9 @@ void statsToBSON(const QuerySolutionNode* node, } case STAGE_TEXT_MATCH: { auto tn = static_cast(node); - + bob->append( + "nss", + NamespaceStringUtil::serialize(tn->nss, SerializationContext::stateDefault())); bob->append("indexPrefix", tn->indexPrefix); bob->append("indexName", tn->index.identifier.catalogName); auto ftsQuery = dynamic_cast(tn->ftsQuery.get()); @@ -480,6 +495,9 @@ void statsToBSON(const QuerySolutionNode* node, } case STAGE_SEARCH: { auto sn = static_cast(node); + bob->append( + "nss", + NamespaceStringUtil::serialize(sn->nss, SerializationContext::stateDefault())); bob->append("isSearchMeta", sn->isSearchMeta); bob->appendNumber("remoteCursorId", static_cast(sn->remoteCursorId)); bob->append("searchQuery", sn->searchQuery); @@ -490,6 +508,13 @@ void statsToBSON(const QuerySolutionNode* node, bob->append("type", eof_node::typeStr(eofn->type)); break; } + case STAGE_FETCH: { + auto fn = static_cast(node); + bob->append( + "nss", + NamespaceStringUtil::serialize(fn->nss, SerializationContext::stateDefault())); + break; + } case STAGE_HASH_JOIN_EMBEDDING_NODE: case STAGE_NESTED_LOOP_JOIN_EMBEDDING_NODE: case STAGE_INDEXED_NESTED_LOOP_JOIN_EMBEDDING_NODE: { @@ -510,6 +535,28 @@ void statsToBSON(const QuerySolutionNode* node, } break; } + case STAGE_INDEX_PROBE_NODE: { + auto ipn = static_cast(node); + bob->append( + "nss", + NamespaceStringUtil::serialize(ipn->nss, SerializationContext::stateDefault())); + bob->append("keyPattern", ipn->index.keyPattern); + bob->append("indexName", ipn->index.identifier.catalogName); + auto collation = + ipn->index.infoObj.getObjectField(IndexDescriptor::kCollationFieldName); + if (!collation.isEmpty()) { + bob->append("collation", collation); + } + bob->appendBool("isMultiKey", ipn->index.multikey); + if (!ipn->index.multikeyPaths.empty()) { + appendMultikeyPaths(ipn->index.keyPattern, ipn->index.multikeyPaths, bob); + } + bob->appendBool("isUnique", ipn->index.unique); + bob->appendBool("isSparse", ipn->index.sparse); + bob->appendBool("isPartial", ipn->index.filterExpr != nullptr); + bob->append("indexVersion", static_cast(ipn->index.version)); + break; + } default: break; } diff --git a/src/mongo/db/query/plan_explainer_test.cpp b/src/mongo/db/query/plan_explainer_test.cpp index 8fee4d2e152..47e11adc367 100644 --- a/src/mongo/db/query/plan_explainer_test.cpp +++ b/src/mongo/db/query/plan_explainer_test.cpp @@ -469,11 +469,13 @@ TEST_F(PlanExplainerTest, HashJoinEmbeddingTest) { { "stage": "COLLSCAN", "planNodeId": 0, + "nss": "testdb.explain", "direction": "forward" }, { "stage": "COLLSCAN", "planNodeId": 0, + "nss": "testdb.foreign_explain", "direction": "forward" } ] @@ -512,11 +514,13 @@ TEST_F(PlanExplainerTest, NLJEmbeddingTest) { { "stage": "COLLSCAN", "planNodeId": 0, + "nss": "testdb.explain", "direction": "forward" }, { "stage": "COLLSCAN", "planNodeId": 0, + "nss": "testdb.foreign_explain", "direction": "forward" } ] @@ -555,11 +559,13 @@ TEST_F(PlanExplainerTest, INLJEmbeddingTest) { { "stage": "COLLSCAN", "planNodeId": 0, + "nss": "testdb.explain", "direction": "forward" }, { "stage": "COLLSCAN", "planNodeId": 0, + "nss": "testdb.foreign_explain", "direction": "forward" } ] diff --git a/src/mongo/db/query/stage_builder/sbe/builder.cpp b/src/mongo/db/query/stage_builder/sbe/builder.cpp index 86b66a1cd48..f828ebf84a0 100644 --- a/src/mongo/db/query/stage_builder/sbe/builder.cpp +++ b/src/mongo/db/query/stage_builder/sbe/builder.cpp @@ -5085,6 +5085,8 @@ std::pair SlotBasedStageBuilder::build(const QuerySolut {STAGE_NESTED_LOOP_JOIN_EMBEDDING_NODE, &SlotBasedStageBuilder::buildNestedLoopJoinEmbeddingNode}, {STAGE_HASH_JOIN_EMBEDDING_NODE, &SlotBasedStageBuilder::buildHashJoinEmbeddingNode}, + {STAGE_INDEXED_NESTED_LOOP_JOIN_EMBEDDING_NODE, + &SlotBasedStageBuilder::buildIndexedJoinEmbeddingNode}, }; tassert(4822884, diff --git a/src/mongo/db/query/stage_builder/sbe/builder.h b/src/mongo/db/query/stage_builder/sbe/builder.h index c0d35bed96e..885a94c6806 100644 --- a/src/mongo/db/query/stage_builder/sbe/builder.h +++ b/src/mongo/db/query/stage_builder/sbe/builder.h @@ -1088,6 +1088,9 @@ private: std::pair buildHashJoinEmbeddingNode(const QuerySolutionNode* root, const PlanStageReqs& reqs); + std::pair buildIndexedJoinEmbeddingNode(const QuerySolutionNode* root, + const PlanStageReqs& reqs); + std::pair buildUnpackTsBucket(const QuerySolutionNode* root, const PlanStageReqs& reqs); diff --git a/src/mongo/db/query/stage_builder/sbe/gen_lookup.cpp b/src/mongo/db/query/stage_builder/sbe/gen_lookup.cpp index ab6881983e4..173f1f7b7f8 100644 --- a/src/mongo/db/query/stage_builder/sbe/gen_lookup.cpp +++ b/src/mongo/db/query/stage_builder/sbe/gen_lookup.cpp @@ -48,6 +48,7 @@ #include "mongo/db/query/query_knobs_gen.h" #include "mongo/db/query/stage_builder/sbe/abt/comparison_op.h" #include "mongo/db/query/stage_builder/sbe/builder.h" +#include "mongo/db/query/stage_builder/sbe/gen_filter.h" #include "mongo/db/query/stage_builder/sbe/gen_helpers.h" #include "mongo/db/query/stage_builder/sbe/gen_projection.h" #include "mongo/db/query/stage_builder/sbe/sbexpr.h" @@ -751,17 +752,15 @@ std::pair buildNljLookupStage( return {matchedRecordsSlot, std::move(nlj)}; } - -std::tuple buildIndexJoinLookupForeignSideStage( - StageBuilderState& state, - SbSlot localKeysSetSlot, - const FieldPath& localFieldName, - const FieldPath& foreignFieldName, - const CollectionPtr& foreignColl, - const IndexEntry& index, - boost::optional collatorSlot, - const PlanNodeId nodeId, - bool hasUnwindSrc) { +std::tuple>> +buildIndexSeekStage(StageBuilderState& state, + SbStage valueGeneratorStage, + SbSlotVector valueForIndexBounds, + std::vector foreignFieldNames, + const CollectionPtr& foreignColl, + const IndexEntry& index, + boost::optional collatorSlot, + const PlanNodeId nodeId) { SbBuilder b(state, nodeId); const auto foreignCollUUID = foreignColl->uuid(); @@ -777,45 +776,49 @@ std::tuple buildIndexJoinLookupForeignSid const auto indexVersion = indexAccessMethod->getSortedDataInterface()->getKeyStringVersion(); const auto indexOrdering = indexAccessMethod->getSortedDataInterface()->getOrdering(); - // Modify the set of values to lookup to include the first item of any array. - auto [localKeysIndexSetSlot, localKeysSetStage] = - buildKeySetForIndexScan(state, b.makeLimitOneCoScanTree(), localKeysSetSlot, nodeId); - - // Unwind local keys one by one into 'valueForIndexBounds'. - auto [valueGeneratorStage, valueForIndexBounds, _] = b.makeUnwind( - std::move(localKeysSetStage), localKeysIndexSetSlot, true /*preserveNullAndEmptyArrays*/); - if (index.type == INDEX_HASHED) { - // For hashed indexes, we need to hash the value before computing keystrings iff the - // lookup's "foreignField" is the hashed field in this index. - const BSONElement elt = index.keyPattern.getField(foreignFieldName.fullPath()); - if (elt.valueStringDataSafe() == IndexNames::HASHED) { - - // For collated hashed indexes, apply collation before hashing. - auto [outStage, outSlots] = - b.makeProject(std::move(valueGeneratorStage), - b.makeFunction("shardHash"_sd, - collatorSlot ? b.makeFunction("collComparisonKey", - valueForIndexBounds, - SbSlot{*collatorSlot}) - : valueForIndexBounds)); - valueGeneratorStage = std::move(outStage); - valueForIndexBounds = outSlots[0]; + for (size_t i = 0; i < foreignFieldNames.size(); i++) { + // For hashed indexes, we need to hash the value before computing keystrings iff the + // lookup's "foreignField" is the hashed field in this index. + const BSONElement elt = index.keyPattern.getField(foreignFieldNames[i].fullPath()); + if (elt.valueStringDataSafe() == IndexNames::HASHED && + valueForIndexBounds[i].getId() != 0) { + // For collated hashed indexes, apply collation before hashing. + auto [outStage, outSlots] = b.makeProject( + std::move(valueGeneratorStage), + b.makeFunction("shardHash"_sd, + collatorSlot ? b.makeFunction("collComparisonKey", + valueForIndexBounds[i], + SbSlot{*collatorSlot}) + : valueForIndexBounds[i])); + valueGeneratorStage = std::move(outStage); + valueForIndexBounds[i] = outSlots[0]; + } } } // Calculate the low key and high key of each individual local field. They are stored in // 'lowKeySlot' and 'highKeySlot', respectively. These two slots will be made available in - // the loop join stage to perform index seek. + // the loop join stage to perform index seek. If the slot has not been initialized, use a + // [MinKey, MaxKey] range. + // TODO: SERVER-114883 support more complex index boundaries by using a GenericIndexScanStage + // rather than a single SimpleIndexScanStage. auto makeNewKeyStringCall = [&](key_string::Discriminator discriminator) { - StringData functionName = "ks"; - SbExpr::Vector args = SbExpr::makeSeq(b.makeInt64Constant(static_cast(indexVersion)), - b.makeInt32Constant(indexOrdering.getBits()), - valueForIndexBounds, - b.makeInt64Constant(static_cast(discriminator))); + b.makeInt32Constant(indexOrdering.getBits())); + for (size_t i = 0; i < valueForIndexBounds.size(); i++) { + if (valueForIndexBounds[i].getId() == 0) { + args.push_back(discriminator == key_string::Discriminator::kExclusiveBefore + ? b.makeConstant(sbe::value::TypeTags::MinKey, 0) + : b.makeConstant(sbe::value::TypeTags::MaxKey, 0)); + } else { + args.push_back(valueForIndexBounds[i]); + } + } + args.push_back(b.makeInt64Constant(static_cast(discriminator))); + StringData functionName = "ks"_sd; if (collatorSlot) { functionName = "collKs"; args.emplace_back(SbSlot{*collatorSlot}); @@ -881,9 +884,19 @@ std::tuple buildIndexJoinLookupForeignSid // stage on the inner side to get matched foreign documents. The foreign documents are // stored in 'foreignRecordSlot'. We also pass in 'snapshotIdSlot', 'indexIdentSlot', // 'indexKeySlot' and 'indexKeyPatternSlot' to perform index consistency check during the seek. - auto [scanNljStage, scanNljValueSlot, scanNljRecordIdSlot, scanNljFieldSlots] = + std::vector topLevelFieldNames; + std::vector> topLevelFields; + StringSet dedupTopLevelFields; + for (auto& foreignFieldName : foreignFieldNames) { + auto topField = std::string(foreignFieldName.front()); + if (dedupTopLevelFields.insert(topField).second) { + topLevelFields.emplace_back(topField, SbSlot{}); + topLevelFieldNames.push_back(std::move(topField)); + } + } + auto [scanNljStage, scanNljValueSlot, scanNljRecordIdSlot, scanNljForeignFieldTopLevelSlots] = makeLoopJoinForFetch(std::move(ixScanNljStage), - std::vector{std::string(foreignFieldName.front())}, + std::move(topLevelFieldNames), foreignRecordIdSlot, snapshotIdSlot, indexIdentSlot, @@ -895,10 +908,48 @@ std::tuple buildIndexJoinLookupForeignSid nodeId, SbSlotVector{} /* slotsToForward */); - return {std::move(scanNljStage), - scanNljValueSlot, - scanNljRecordIdSlot, - std::move(scanNljFieldSlots)}; + for (size_t i = 0; i < topLevelFields.size(); i++) { + topLevelFields[i].second = std::move(scanNljForeignFieldTopLevelSlots[i]); + } + + return { + std::move(scanNljStage), scanNljValueSlot, scanNljRecordIdSlot, std::move(topLevelFields)}; +} + +std::tuple buildIndexJoinLookupForeignSideStage( + StageBuilderState& state, + SbSlot localKeysSetSlot, + const FieldPath& localFieldName, + const FieldPath& foreignFieldName, + const CollectionPtr& foreignColl, + const IndexEntry& index, + boost::optional collatorSlot, + const PlanNodeId nodeId, + bool hasUnwindSrc) { + SbBuilder b(state, nodeId); + + // Modify the set of values to lookup to include the first item of any array. + auto [localKeysIndexSetSlot, localKeysSetStage] = + buildKeySetForIndexScan(state, b.makeLimitOneCoScanTree(), localKeysSetSlot, nodeId); + + // Unwind local keys one by one into 'valueForIndexBounds'. + auto [valueGeneratorStage, valueForIndexBounds, _] = b.makeUnwind( + std::move(localKeysSetStage), localKeysIndexSetSlot, true /*preserveNullAndEmptyArrays*/); + + auto [stage, valueSlot, recordIdSlot, foreignFieldTopLevelSlots] = + buildIndexSeekStage(state, + std::move(valueGeneratorStage), + {valueForIndexBounds}, + {foreignFieldName}, + foreignColl, + index, + collatorSlot, + nodeId); + + return {std::move(stage), + std::move(valueSlot), + std::move(recordIdSlot), + std::move(foreignFieldTopLevelSlots[0].second)}; } // buildIndexJoinLookupForeignSideStage /* @@ -943,7 +994,7 @@ std::pair buildIndexJoinLookupStage( state, std::move(localStage), slots, localFieldName, collatorSlot, nodeId); // Build the inner branch that produces the correlated foreign key slot. - auto [scanNljStage, foreignRecordSlot, _, scanFieldSlots] = + auto [scanNljStage, foreignRecordSlot, _, foreignFieldTopLevelSlot] = buildIndexJoinLookupForeignSideStage(state, localKeysSetSlot, localFieldName, @@ -962,7 +1013,7 @@ std::pair buildIndexJoinLookupStage( std::move(scanNljStage), foreignRecordSlot, foreignFieldName, - scanFieldSlots[0], + foreignFieldTopLevelSlot, nodeId, state, hasUnwindSrc); @@ -1036,21 +1087,22 @@ std::pair buildDynamicIndexedLoopJoinLookupStage( auto [indexLookupBranchStage, indexLookupBranchResultSlot, indexLookupBranchRecordIdSlot, - indexLookupBranchScanSlots] = buildIndexJoinLookupForeignSideStage(state, - localKeysSetSlot, - localFieldName, - foreignFieldName, - foreignColl, - index, - collatorSlot, - nodeId, - hasUnwindSrc); + indexLookupBranchForeignFieldTopLevelSlot] = + buildIndexJoinLookupForeignSideStage(state, + localKeysSetSlot, + localFieldName, + foreignFieldName, + foreignColl, + index, + collatorSlot, + nodeId, + hasUnwindSrc); // Build the nested loop branch. auto [nestedLoopBranchStage, nestedLoopBranchResultSlot, nestedLoopBranchRecordIdSlot, - nestedLoopBranchScanSlots] = + nestedLoopBranchForeignFieldTopLevelSlots] = b.makeScan(foreignColl->uuid(), foreignColl->ns().dbName(), forwardScanDirection, @@ -1071,15 +1123,16 @@ std::pair buildDynamicIndexedLoopJoinLookupStage( b.makeBoolConstant(false) /*compareArray*/)); // Create a branch stage - auto [branchStage, branchSlots] = b.makeBranch(std::move(indexLookupBranchStage), - std::move(nestedLoopBranchStage), - std::move(filter), - SbExpr::makeSV(indexLookupBranchResultSlot, - indexLookupBranchRecordIdSlot, - indexLookupBranchScanSlots[0]), - SbExpr::makeSV(nestedLoopBranchResultSlot, - nestedLoopBranchRecordIdSlot, - nestedLoopBranchScanSlots[0])); + auto [branchStage, branchSlots] = + b.makeBranch(std::move(indexLookupBranchStage), + std::move(nestedLoopBranchStage), + std::move(filter), + SbExpr::makeSV(indexLookupBranchResultSlot, + indexLookupBranchRecordIdSlot, + indexLookupBranchForeignFieldTopLevelSlot), + SbExpr::makeSV(nestedLoopBranchResultSlot, + nestedLoopBranchRecordIdSlot, + nestedLoopBranchForeignFieldTopLevelSlots[0])); SbSlot resultSlot = branchSlots[0]; auto [finalForeignSlot, finalForeignStage] = buildForeignMatches(localKeysSetSlot, @@ -1484,11 +1537,6 @@ std::pair SlotBasedStageBuilder::buildEqLookupUnwind( } // buildEqLookupUnwind namespace { -PlanStageReqs makeReqsForRightSideOfNestedLoopJoin( - const QuerySolutionNode* root, std::vector fieldRequests) { - return PlanStageReqs{}.setResultObj().set(std::move(fieldRequests)); -} - /** * Generates an expression for evaluating a path that takes the value found at the first path * component and returns a single value from evaluating the remaining path components. The @@ -1793,8 +1841,7 @@ std::pair SlotBasedStageBuilder::buildNestedLoopJoinEmb auto [leftStage, leftOutputs] = build(nestedLoopJoinEmbeddingNode->children[0].get(), leftChildReqs); - PlanStageReqs rightChildReqs = makeReqsForRightSideOfNestedLoopJoin( - nestedLoopJoinEmbeddingNode->children[1].get(), std::move(rightRequests)); + PlanStageReqs rightChildReqs = PlanStageReqs{}.setResultObj().set(std::move(rightRequests)); auto [rightStage, rightOutputs] = build(nestedLoopJoinEmbeddingNode->children[1].get(), rightChildReqs); @@ -1907,8 +1954,7 @@ std::pair SlotBasedStageBuilder::buildHashJoinEmbedding .set(std::move(leftRequests)); auto [leftStage, leftOutputs] = build(hashJoinEmbeddingNode->children[0].get(), leftChildReqs); - PlanStageReqs rightChildReqs = makeReqsForRightSideOfNestedLoopJoin( - hashJoinEmbeddingNode->children[1].get(), std::move(rightRequests)); + PlanStageReqs rightChildReqs = PlanStageReqs{}.setResultObj().set(std::move(rightRequests)); auto [rightStage, rightOutputs] = build(hashJoinEmbeddingNode->children[1].get(), rightChildReqs); @@ -1961,4 +2007,165 @@ std::pair SlotBasedStageBuilder::buildHashJoinEmbedding _state); } +/** + * Build an equijoin operation according to the input STAGE_INDEXED_NESTED_LOOP_JOIN_EMBEDDING_NODE + * plan. This style of join is simpler than general-purpose $lookup joins, because it only supports + * equality predicates with path operands that never implicitly traverse an array. + */ +std::pair SlotBasedStageBuilder::buildIndexedJoinEmbeddingNode( + const QuerySolutionNode* root, const PlanStageReqs& reqs) { + tassert( + 11122200, "buildIndexedJoinEmbeddingNode() does not support kSortKey", !reqs.hasSortKeys()); + + SbBuilder b(_state, root->nodeId()); + + auto indexedJoinEmbeddingNode = static_cast(root); + + auto [leftRequests, rightRequests] = + collectRequestedFields(indexedJoinEmbeddingNode, reqs, _qsnAnalysis); + + auto& fieldEffect = _qsnAnalysis.getQsnInfo(root).effects; + tassert(11122201, "Expected field effect set to be computed", fieldEffect); + + // Recursively build the executable plan for the left side of the join. + PlanStageReqs leftChildReqs = + PlanStageReqs{} + .setResultInfo(FieldSet::makeOpenSet(std::vector{}), FieldEffects()) + .set(std::move(leftRequests)); + auto [leftStage, leftOutputs] = + build(indexedJoinEmbeddingNode->children[0].get(), leftChildReqs); + + // Don't use recursion to build the index scan on the right side of the join, we have to + // manually inject the predicate. + auto indexFetch = dynamic_cast(indexedJoinEmbeddingNode->children[1].get()); + tassert(11122202, + "Right child in buildIndexedJoinEmbeddingNode() must be an FetchNode", + indexFetch != nullptr); + auto indexProbe = dynamic_cast(indexFetch->children[0].get()); + tassert(11122203, + "Right grandchild in buildIndexedJoinEmbeddingNode() must be an IndexProbeNode", + indexProbe != nullptr); + + const auto foreignColl = _collections.lookupCollection(indexProbe->nss); + tassert(ErrorCodes::NamespaceNotFound, + str::stream() << "Collection " << indexProbe->nss.toStringForErrorMsg() + << " has been dropped", + foreignColl); + tassert(ErrorCodes::NamespaceNotFound, + str::stream() << "Collection " << indexProbe->nss.toStringForErrorMsg() + << " has been renamed", + foreignColl->ns() == indexProbe->nss); + + // Populate a map assigning to each key component its position in the key pattern, we can't be + // sure that the paths from the right sides of the predicates are in the order used in the index + // definition. + StringMap indexKeyPos; + size_t pos = 0; + for (auto& key : indexProbe->index.keyPattern) { + indexKeyPos[std::string(key.fieldNameStringData())] = pos++; + } + SbExprOptSlotVector leftPrj; + std::vector foreignPaths; + StringSet dedupForeignPaths; + for (const auto& predicate : indexedJoinEmbeddingNode->joinPredicates) { + tassert(11122204, + "Unknown operation in join predicate", + predicate.op == QSNJoinPredicate::ComparisonOp::Eq); + + // Create an expression for the left side of the predicate, and add it to a ProjectStage + // to be placed on top of the source stages. Any path that fails to evaluate, because of a + // missing or non-object path component, gets treated as if it evaluated to a null value for + // the purposes of this comparison. This behavior matches MQL localField/foreignField + // $lookup semantics. + leftPrj.emplace_back(b.makeFillEmptyNull(generateArrayObliviousPathEvaluation( + b, predicate.leftField, leftOutputs)), + boost::none); + if (dedupForeignPaths.emplace(predicate.rightField.fullPath()).second) { + foreignPaths.push_back(predicate.rightField); + } + } + // Ensure that the FetchStage on top of the found entries exports the fields that we require + // from this side. + for (auto& [type, name] : rightRequests) { + if (type == PlanStageSlots::SlotType::kField) { + if (dedupForeignPaths.emplace(name).second) { + foreignPaths.push_back(name); + } + } + } + + // Project the computed predicates from the left side. + auto [leftPrjStage, leftPrjOutputs] = + b.makeProject(b.makeLimitOneCoScanTree(), std::move(leftPrj)); + + // Associate the predicates from the left side of the predicate to the position of the right + // side in the key pattern. If an index column is not used in a predicate, it will be left + // assigned to slot 0, and the buildIndexSeekStage will insert a [MinKey,MaxKey] bound for it. + SbSlotVector keyParts; + keyParts.resize(indexProbe->index.keyPattern.nFields()); + for (size_t predicateIndex = 0; + predicateIndex < indexedJoinEmbeddingNode->joinPredicates.size(); + predicateIndex++) { + if (auto it = indexKeyPos.find( + indexedJoinEmbeddingNode->joinPredicates[predicateIndex].rightField.fullPath()); + it != indexKeyPos.end()) { + keyParts[it->second] = leftPrjOutputs[predicateIndex++]; + } + } + + auto [outStage, outputDocSlot, _, topLevelFieldSlots] = + buildIndexSeekStage(_state, + std::move(leftPrjStage), + keyParts, + foreignPaths, + foreignColl, + indexProbe->index, + _state.getCollatorSlot(), + indexFetch->nodeId()); + + PlanStageSlots rightOutputs; + rightOutputs.setResultObj(outputDocSlot); + for (auto& [topLevelField, slot] : topLevelFieldSlots) { + rightOutputs.set(std::make_pair(PlanStageSlots::SlotType::kField, topLevelField), slot); + } + + if (indexFetch->filter) { + auto filterExpr = + generateFilter(_state, indexFetch->filter.get(), outputDocSlot, rightOutputs); + if (!filterExpr.isNull()) { + outStage = b.makeFilter(std::move(outStage), std::move(filterExpr)); + } + } + + // Create a filter based on the join predicate in order to handle cases where index bounds are + // inexact. + SbExpr::Vector equalityPredicates; + equalityPredicates.reserve(indexedJoinEmbeddingNode->joinPredicates.size()); + for (const auto& predicate : indexedJoinEmbeddingNode->joinPredicates) { + equalityPredicates.emplace_back(b.makeBinaryOp( + abt::Operations::Eq, + b.makeFillEmptyNull( + generateArrayObliviousPathEvaluation(b, predicate.leftField, leftOutputs)), + b.makeFillEmptyNull( + generateArrayObliviousPathEvaluation(b, predicate.rightField, rightOutputs)))); + } + + // Finally, get the keys from the outer side and feed them to the inner side (ixscan). + auto indexStage = + b.makeLoopJoin(std::move(leftStage), + std::move(outStage), + leftOutputs.getAllSlotsInOrder() /* outerProjects */, + leftOutputs.getAllSlotsInOrder() /* outerCorrelated */, + {}, /* innerProjects */ + b.makeBooleanOpTree(abt::Operations::And, std::move(equalityPredicates))); + + return generateJoinResult(indexedJoinEmbeddingNode, + reqs, + std::move(indexStage), + leftOutputs, + rightOutputs, + *fieldEffect, + _state); +} + } // namespace mongo::stage_builder diff --git a/src/mongo/db/test_output/query/join/reorder_graph_test/avoid_i_n_l_j_over_ineligible_index.txt b/src/mongo/db/test_output/query/join/reorder_graph_test/avoid_i_n_l_j_over_ineligible_index.txt index 20f69ddeeb8..ecd0677680b 100644 --- a/src/mongo/db/test_output/query/join/reorder_graph_test/avoid_i_n_l_j_over_ineligible_index.txt +++ b/src/mongo/db/test_output/query/join/reorder_graph_test/avoid_i_n_l_j_over_ineligible_index.txt @@ -39,6 +39,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.a ---------nodeId = 3 ---------fetched = 1 ---------sortedByDiskLoc = 0 diff --git a/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_compound_join_predicate.txt b/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_compound_join_predicate.txt index b0a3c435e15..46f82e9db3c 100644 --- a/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_compound_join_predicate.txt +++ b/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_compound_join_predicate.txt @@ -17,6 +17,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.b ---------nodeId = 3 ---------fetched = 1 ---------sortedByDiskLoc = 0 diff --git a/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_residual_pred.txt b/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_residual_pred.txt index be47a814e14..a2820b58da6 100644 --- a/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_residual_pred.txt +++ b/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_residual_pred.txt @@ -16,6 +16,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.b ---------filter: b $gt 5 ---------nodeId = 3 diff --git a/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_use_index_prefix.txt b/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_use_index_prefix.txt index 398c437d8f8..33039ac31c6 100644 --- a/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_use_index_prefix.txt +++ b/src/mongo/db/test_output/query/join/reorder_graph_test/i_n_l_j_use_index_prefix.txt @@ -16,6 +16,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.b ---------nodeId = 3 ---------fetched = 1 ---------sortedByDiskLoc = 0 diff --git a/src/mongo/db/test_output/query/join/reorder_graph_test/multiple_i_n_l_j.txt b/src/mongo/db/test_output/query/join/reorder_graph_test/multiple_i_n_l_j.txt index 2d0aef66555..5609371e34b 100644 --- a/src/mongo/db/test_output/query/join/reorder_graph_test/multiple_i_n_l_j.txt +++ b/src/mongo/db/test_output/query/join/reorder_graph_test/multiple_i_n_l_j.txt @@ -30,6 +30,7 @@ INDEXED_NESTED_LOOP_JOIN ---------------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.b ---------nodeId = 5 ---------fetched = 1 ---------sortedByDiskLoc = 0 @@ -60,6 +61,7 @@ INDEXED_NESTED_LOOP_JOIN ---------------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---------Inner: ------------FETCH +---------------ns = test.c ---------------nodeId = 3 ---------------fetched = 1 ---------------sortedByDiskLoc = 0 @@ -69,6 +71,7 @@ INDEXED_NESTED_LOOP_JOIN ---------------------Namespace: test.c Index: { c: 1 } ---Inner: ------FETCH +---------ns = test.b ---------nodeId = 6 ---------fetched = 1 ---------sortedByDiskLoc = 0 diff --git a/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j.txt b/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j.txt index 2fdac91675f..cf7af84a5ec 100644 --- a/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j.txt +++ b/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j.txt @@ -16,6 +16,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.b ---------nodeId = 3 ---------fetched = 1 ---------sortedByDiskLoc = 0 @@ -40,6 +41,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.a ---------nodeId = 3 ---------fetched = 1 ---------sortedByDiskLoc = 0 diff --git a/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j_swap_edge.txt b/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j_swap_edge.txt index 2318e0be8fb..b024f74874f 100644 --- a/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j_swap_edge.txt +++ b/src/mongo/db/test_output/query/join/reorder_graph_test/simple_i_n_l_j_swap_edge.txt @@ -16,6 +16,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.b ---------nodeId = 3 ---------fetched = 1 ---------sortedByDiskLoc = 0 @@ -40,6 +41,7 @@ INDEXED_NESTED_LOOP_JOIN ---------providedSorts = {baseSortPattern: {}, ignoredFields: []} ---Inner: ------FETCH +---------ns = test.a ---------nodeId = 3 ---------fetched = 1 ---------sortedByDiskLoc = 0