summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_tree_test.cpp
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@mongodb.com>2019-10-18 13:13:38 +0000
committerevergreen <evergreen@mongodb.com>2019-10-18 13:13:38 +0000
commit6ca9be706ce03a2c79d29feac3cfd294cc09445d (patch)
tree647b25156fd48d8dd5cc736cf0ec3c264f1976e7 /src/mongo/db/query/query_planner_tree_test.cpp
parentdab2ae229660af56a786a084ebc36666c4dd6a91 (diff)
downloadmongo-6ca9be706ce03a2c79d29feac3cfd294cc09445d.tar.gz
SERVER-41872 PlanEnumerator AndAssignment::choices ordering not stable and is relevant to set of plans generated
Diffstat (limited to 'src/mongo/db/query/query_planner_tree_test.cpp')
-rw-r--r--src/mongo/db/query/query_planner_tree_test.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/mongo/db/query/query_planner_tree_test.cpp b/src/mongo/db/query/query_planner_tree_test.cpp
index 1e82fd1fb1d..e875163254d 100644
--- a/src/mongo/db/query/query_planner_tree_test.cpp
+++ b/src/mongo/db/query/query_planner_tree_test.cpp
@@ -2307,6 +2307,68 @@ TEST_F(QueryPlannerTest, ContainedOrPushdownIndexedExpr) {
assertSolutionExists("{cscan: {dir: 1}}}}");
}
+// SERVER-41872 fixed a case where variable "choice" ordering in the PlanEnumerator memo could lead
+// to different sets of solutions generated for the same input. This would occur in the case where
+// we only enumerate a subset of possible plans due to reaching internal limits and enumerate plans
+// in a non-stable order. With the fix for SERVER-41872, PlanEnumerator ordering is stable and
+// expected to always return the same set of solutions for a given input.
+TEST_F(QueryPlannerTest, SolutionSetStableWhenOrEnumerationLimitIsReached) {
+ params.options = QueryPlannerParams::NO_TABLE_SCAN;
+ addIndex(BSON("d" << 1));
+ addIndex(BSON("e" << 1));
+ addIndex(BSON("f" << 1));
+ addIndex(BSON("f" << 1 << "y" << 1));
+ addIndex(BSON("a" << 1));
+ addIndex(BSON("b" << 1));
+ addIndex(BSON("c" << 1));
+ addIndex(BSON("c" << 1 << "x" << 1));
+
+ runQueryAsCommand(
+ fromjson("{find: 'testns', filter: {$or: [{a: 1, b: 1, c: 1}, {d: 1, e: 1, f: 1}]}}"));
+
+ assertNumSolutions(10U);
+
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {b: {$eq: 1}, c: {$eq: 1} }, node: {ixscan: {pattern: {a: "
+ "1}}}}}, {fetch: {filter: {e: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {d: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {a: {$eq: 1}, c: {$eq: 1} }, node: {ixscan: {pattern: {b: "
+ "1}}}}}, {fetch: {filter: {e: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {d: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {a: {$eq: 1}, b: {$eq: 1} }, node: {ixscan: {pattern: {c: "
+ "1}}}}}, {fetch: {filter: {e: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {d: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {a: {$eq: 1}, b: {$eq: 1} }, node: {ixscan: {pattern: {c: "
+ "1, x: 1}}}}}, {fetch: {filter: {e: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {d: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {b: {$eq: 1}, c: {$eq: 1} }, node: {ixscan: {pattern: {a: "
+ "1}}}}}, {fetch: {filter: {d: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {e: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {a: {$eq: 1}, c: {$eq: 1} }, node: {ixscan: {pattern: {b: "
+ "1}}}}}, {fetch: {filter: {d: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {e: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {a: {$eq: 1}, b: {$eq: 1} }, node: {ixscan: {pattern: {c: "
+ "1}}}}}, {fetch: {filter: {d: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {e: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {a: {$eq: 1}, b: {$eq: 1} }, node: {ixscan: {pattern: {c: "
+ "1, x: 1}}}}}, {fetch: {filter: {d: {$eq: 1}, f: {$eq: 1} }, node: {ixscan: {pattern: {e: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {b: {$eq: 1}, c: {$eq: 1} }, node: {ixscan: {pattern: {a: "
+ "1}}}}}, {fetch: {filter: {d: {$eq: 1}, e: {$eq: 1} }, node: {ixscan: {pattern: {f: "
+ "1}}}}}]}}");
+ assertSolutionExists(
+ "{or: {nodes: [{fetch: {filter: {a: {$eq: 1}, c: {$eq: 1} }, node: {ixscan: {pattern: {b: "
+ "1}}}}}, {fetch: {filter: {d: {$eq: 1}, e: {$eq: 1} }, node: {ixscan: {pattern: {f: "
+ "1}}}}}]}}");
+}
} // namespace
} // namespace mongo