diff options
author | David Storch <david.storch@mongodb.com> | 2019-11-26 19:54:39 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-26 19:54:39 +0000 |
commit | 058c4e3bbf94aa2ed1148dd0e8e473be6fcaa48b (patch) | |
tree | d292327f61eaee9f9c487162516d89c6ebc1a70c /src/mongo/db/query/query_planner_collation_test.cpp | |
parent | 2b70f6f0d7cf33dd387b50141992362fc4e2fcf8 (diff) | |
download | mongo-058c4e3bbf94aa2ed1148dd0e8e473be6fcaa48b.tar.gz |
SERVER-15200 Optimize projection to occur before sort when possible.
When the projection is statically known to reduce the size
of the data (i.e. when the projection does not add any newly
computed fields), then evaluating the projection first is
beneficial because it reduces the size of the data which
must be sorted.
Diffstat (limited to 'src/mongo/db/query/query_planner_collation_test.cpp')
-rw-r--r-- | src/mongo/db/query/query_planner_collation_test.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/mongo/db/query/query_planner_collation_test.cpp b/src/mongo/db/query/query_planner_collation_test.cpp index 5cefee957c1..806e0c0f54d 100644 --- a/src/mongo/db/query/query_planner_collation_test.cpp +++ b/src/mongo/db/query/query_planner_collation_test.cpp @@ -581,8 +581,8 @@ TEST_F(QueryPlannerTest, CanProduceCoveredSortPlanWhenQueryHasCollationButIndexD assertNumSolutions(1U); assertSolutionExists( - "{proj: {spec: {a: 1, b:1, _id: 0}, node: {sort: {pattern: {a: 1, b: 1}, limit: 0, node: " - "{sortKeyGen:{node: {ixscan: {pattern: {a: 1, b: 1}}}}}}}}}"); + "{sort: {pattern: {a: 1, b: 1}, limit: 0, node: {sortKeyGen: {node: " + "{proj: {spec: {a: 1, b: 1, _id: 0}, node: {ixscan: {pattern: {a: 1, b: 1}}}}}}}}}"); } TEST_F(QueryPlannerTest, CannotUseIndexWhenQueryHasNoCollationButIndexHasNonSimpleCollation) { @@ -594,8 +594,8 @@ TEST_F(QueryPlannerTest, CannotUseIndexWhenQueryHasNoCollationButIndexHasNonSimp assertNumSolutions(1U); assertSolutionExists( - "{proj: {spec: {a: 1, b:1, _id: 0}, node: {sort: {pattern: {a: 1, b: 1}, limit: 0, node: " - "{sortKeyGen:{node: {cscan: {dir: 1}}}}}}}}"); + "{sort: {pattern: {a: 1, b: 1}, limit: 0, node: {sortKeyGen: {node: " + "{proj: {spec: {a: 1, b: 1, _id: 0}, node: {cscan: {dir: 1}}}}}}}}"); } TEST_F(QueryPlannerTest, CannotUseIndexWhenQueryHasDifferentNonSimpleCollationThanIndex) { @@ -608,8 +608,8 @@ TEST_F(QueryPlannerTest, CannotUseIndexWhenQueryHasDifferentNonSimpleCollationTh assertNumSolutions(1U); assertSolutionExists( - "{proj: {spec: {a: 1, b:1, _id: 0}, node: {sort: {pattern: {a: 1, b: 1}, limit: 0, node: " - "{sortKeyGen:{node: {cscan: {dir: 1}}}}}}}}"); + "{sort: {pattern: {a: 1, b: 1}, limit: 0, node: {sortKeyGen: {node: " + "{proj: {spec: {a: 1, b: 1, _id: 0}, node: {cscan: {dir: 1}}}}}}}}"); } /** @@ -625,14 +625,14 @@ TEST_F(QueryPlannerTest, MustFetchBeforeSortWhenQueryHasSameNonSimpleCollationAs runQueryAsCommand( fromjson("{find: 'testns', filter: {a: {$gt: 0}}, projection: {a: 1, b:1, _id: 0}, " - "collation: {locale: " - "'reverse'}, sort: {b: 1, a: 1}}")); + "collation: {locale: 'reverse'}, sort: {b: 1, a: 1}}")); assertNumSolutions(1U); assertSolutionExists( - "{proj: {spec: {a: 1, b:1, _id: 0}, node: {sort: {pattern: {b: 1, a: 1}, limit: 0, node: " - "{sortKeyGen:{node: {fetch: {filter: null, collation: {locale: 'reverse'}, node: {ixscan: " - "{pattern: {a: 1, b: 1}}}}}}}}}}}}}"); + "{sort: {pattern: {b: 1, a: 1}, limit: 0, node: {sortKeyGen: {node:" + "{proj: {spec: {a: 1, b: 1, _id: 0}, node:" + "{fetch: {filter: null, collation: {locale: 'reverse'}, node:" + "{ixscan: {pattern: {a: 1, b: 1}}}}}}}}}}}}}"); } TEST_F(QueryPlannerTest, NoSortStageWhenMinMaxIndexCollationDoesNotMatchButBoundsContainNoStrings) { |