diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2020-11-02 16:44:44 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2020-11-02 16:44:44 -0500 |
commit | d7231fc0c2a18d101d315ff68349b95dfb264150 (patch) | |
tree | 638664a9f70ab77f1149ac3c8e51513dcc84f18f /src/mongo | |
parent | d8a6a927105e9b898d85a5db16ef97f3b24d8c40 (diff) | |
download | mongo-d7231fc0c2a18d101d315ff68349b95dfb264150.tar.gz |
Revert "SERVER-41872 PlanEnumerator AndAssignment::choices ordering not stable and is relevant to set of plans generated"r3.6.21-rc1
This reverts commit b010331e00cb46efe4e98e0f74150854b4407d67.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/query/plan_enumerator.h | 10 | ||||
-rw-r--r-- | src/mongo/db/query/query_planner_test.cpp | 63 |
2 files changed, 2 insertions, 71 deletions
diff --git a/src/mongo/db/query/plan_enumerator.h b/src/mongo/db/query/plan_enumerator.h index 8b563ed145b..53643b2a95c 100644 --- a/src/mongo/db/query/plan_enumerator.h +++ b/src/mongo/db/query/plan_enumerator.h @@ -430,16 +430,10 @@ private: */ bool alreadyCompounded(const std::set<MatchExpression*>& ixisectAssigned, const AndAssignment* andAssignment); - - struct CmpByIndexID { - bool operator()(IndexID a, IndexID b) const { - return a < b; - } - }; /** - * Maps from index id to the list of predicates assigned to that index. + * Output index intersection assignments inside of an AND node. */ - typedef std::map<IndexID, std::vector<MatchExpression*>, CmpByIndexID> IndexToPredMap; + typedef unordered_map<IndexID, std::vector<MatchExpression*>> IndexToPredMap; /** * Generate index intersection assignments given the predicate/index structure in idxToFirst diff --git a/src/mongo/db/query/query_planner_test.cpp b/src/mongo/db/query/query_planner_test.cpp index 58645fc9efc..f27c7a1e46c 100644 --- a/src/mongo/db/query/query_planner_test.cpp +++ b/src/mongo/db/query/query_planner_test.cpp @@ -5624,69 +5624,6 @@ TEST_F(QueryPlannerTest, EmptyQueryWithProjectionUsesCollscanIfIndexCollationDif "{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}}}}}]}}"); -} - TEST_F(QueryPlannerTest, InvalidUtf8CodePointDoesNotLeadToInvalidIndexBoundsInvariantFailure) { params.options &= ~QueryPlannerParams::INCLUDE_COLLSCAN; addIndex(BSON("a" << 1)); |