diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2021-04-15 10:08:30 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2021-04-15 10:08:30 -0400 |
commit | ebecb2102d4b34f72dbba63854555ab0ea761287 (patch) | |
tree | 6e19d0323f2934d6f06c8391c8ff9cb40e8126c8 /src | |
parent | fb8ebd45d807b2adb803d386437e43ebeb5e436f (diff) | |
download | mongo-ebecb2102d4b34f72dbba63854555ab0ea761287.tar.gz |
File ticket and update TODO comments for known planner limitation
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/query/planner_wildcard_helpers_test.cpp | 21 | ||||
-rw-r--r-- | src/mongo/db/query/query_planner_array_test.cpp | 13 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/mongo/db/query/planner_wildcard_helpers_test.cpp b/src/mongo/db/query/planner_wildcard_helpers_test.cpp index 770f962c851..1a59f036580 100644 --- a/src/mongo/db/query/planner_wildcard_helpers_test.cpp +++ b/src/mongo/db/query/planner_wildcard_helpers_test.cpp @@ -243,8 +243,8 @@ protected: // assertNumSolutions(1U); // assertSolutionExists( // "{fetch: {node: {ixscan: {pattern: {a: 1, $_path: 1, x: 1}, bounds: {'a': " -// "[[5, 5, true, true]], '$_path': [['x', 'x', true, true]], 'x': [['MinKey', 'MaxKey', true, " -// "true]]}}}}}"); +// "[[5, 5, true, true]], '$_path': [['x', 'x', true, true]], 'x': [['MinKey', 'MaxKey', +// true, " "true]]}}}}}"); // } TEST_F(QueryPlannerWildcardTest, CompoundWildcardIndexBasic) { @@ -297,19 +297,21 @@ TEST_F(QueryPlannerWildcardTest, addWildcardIndex(fromjson("{x: 1, '$**': 1}"), {"a"}, fromjson("{x: 0}")); runQuery(fromjson("{x: {$lt: 2}, 'a.b': {$gt: 0, $lt: 9}}")); - // TODO: in query_planner_wildcard_index_test.cpp, the original test gave 2 solutions, not one. - // Feels like a bug... - // I have to admit I'm confused about the bounds in the original test too -- For example, in the - // solution here, we can't we use the bounds for 'a.b': [[0, 20, false false]]? assertNumSolutions(1U); assertSolutionExists( "{fetch: {filter: {'a.b': {$gt: 0}}, node: " "{ixscan: {filter: null, pattern: {'x': 1, '$_path': 1, 'a.b': 1}," "bounds: {'x': [[-Infinity, 2, true, false]], '$_path': [['a.b','a.b',true,true]], 'a.b': " "[[-Infinity,9,true,false]]}}}}}"); + // TODO SERVER-56118 This solution should be generated. + // assertSolutionExists( + // "{fetch: {filter: {'a.b': {$gt: 0}}, node: " + // "{ixscan: {filter: null, pattern: {'x': 1, '$_path': 1, 'a.b': 1}," + // "bounds: {'x': [[-Infinity, 2, true, false]], '$_path': [['a.b','a.b',true,true]], 'a.b': + // " + // "[[0,Infinity,false,true]]}}}}}"); } - TEST_F(QueryPlannerWildcardTest, CompoundWildcardAllPredsEligibleForIndexUseGenerateCandidatePlans) { addWildcardIndex(fromjson("{x: 1, 'a.$**': 1}"), {"a.b", "a.c"}); @@ -317,7 +319,8 @@ TEST_F(QueryPlannerWildcardTest, fromjson("{x: {$eq: 2}, 'a.b': {$gt: 0, $lt: 9}, 'a.c': {$gt: 11, $lt: 20}, d: {$gt: 31, " "$lt: 40}}")); - // TODO: Same as above: the original test gave 4 solutions, not two. + // TODO SERVER-56118: Should generate 4 plans here. Missing the plans where $gts are bounded + // instead of $lts. assertNumSolutions(2U); assertSolutionExists( "{fetch: {filter: {'a.b':{$gt:0,$lt: 9},'a.c':{$gt:11},d:{$gt:31,$lt:40}}, node: " @@ -330,4 +333,4 @@ TEST_F(QueryPlannerWildcardTest, "bounds: {'x': [[2, 2, true, true]], '$_path': [['a.b','a.b',true,true]], 'a.b': " "[[-Infinity,9,true,false]]}}}}}"); } -} // namespace mongo
\ No newline at end of file +} // namespace mongo diff --git a/src/mongo/db/query/query_planner_array_test.cpp b/src/mongo/db/query/query_planner_array_test.cpp index 089c6e70848..adac862252b 100644 --- a/src/mongo/db/query/query_planner_array_test.cpp +++ b/src/mongo/db/query/query_planner_array_test.cpp @@ -1276,6 +1276,19 @@ TEST_F(QueryPlannerTest, CannotIntersectBoundsWhenSecondFieldIsMultikey) { assertSolutionExists( "{fetch: {node: {ixscan: {pattern: {a: 1, b: 1}, " "bounds: {a: [[2, 2, true, true]], b: [[-Infinity, 10, true, false]]}}}}}"); + // TODO SERVER-56118 expect to see another plan with (0, Infinity] also. +} + +TEST_F(QueryPlannerTest, CanBuildGtBoundsOnSecondFieldIfFirstIsMultikey) { + MultikeyPaths multikeyPaths{MultikeyComponents{}, {0U}}; + addIndex(BSON("a" << 1 << "b" << 1), multikeyPaths); + runQuery(fromjson("{a: 2, b: {$gte: 0}}")); + + assertNumSolutions(2U); + assertSolutionExists("{cscan: {dir: 1, filter: {a: 2, b: {$gte: 0}}}}"); + assertSolutionExists( + "{fetch: {node: {ixscan: {pattern: {a: 1, b: 1}, " + "bounds: {a: [[2, 2, true, true]], b: [[0, Infinity, true, true]]}}}}}"); } TEST_F(QueryPlannerTest, CanIntersectBoundsWhenSecondFieldIsMultikeyButHasElemMatch) { |