summaryrefslogtreecommitdiff
path: root/jstests/aggregation
diff options
context:
space:
mode:
authorDan Larkin-York <dan.larkin-york@mongodb.com>2023-02-03 23:42:29 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-04 01:32:37 +0000
commit94098eff431d7bb65da31516cc4df2a895d27dd8 (patch)
tree1aa862702400ebbf57026aa94e766b8d88b9e143 /jstests/aggregation
parent946646ef8d624116985f3acca5ec5ae359d59097 (diff)
downloadmongo-94098eff431d7bb65da31516cc4df2a895d27dd8.tar.gz
Revert "SERVER-71798 Expand the set of queries eligible for SBE in the 6.3 release"
Diffstat (limited to 'jstests/aggregation')
-rw-r--r--jstests/aggregation/add_with_date.js2
-rw-r--r--jstests/aggregation/explain_limit.js2
-rw-r--r--jstests/aggregation/optimize_away_pipeline.js89
3 files changed, 44 insertions, 49 deletions
diff --git a/jstests/aggregation/add_with_date.js b/jstests/aggregation/add_with_date.js
index 4d76a6908d7..b80c304e42c 100644
--- a/jstests/aggregation/add_with_date.js
+++ b/jstests/aggregation/add_with_date.js
@@ -28,6 +28,8 @@ assert.commandWorked(coll.insert({
nanDecimal: NumberDecimal("NaN"),
}));
+const isSBEEnabled = checkSBEEnabled(db, ["featureFlagSbeFull"]);
+
// Adding a Decimal128 value to a date literal.
assert.eq(ISODate("2019-01-30T07:30:10.957Z"),
getResultOfExpression({$add: ["$decimalVal", ISODate("2019-01-30T07:30:10.137Z")]}));
diff --git a/jstests/aggregation/explain_limit.js b/jstests/aggregation/explain_limit.js
index 5e017f9b74e..7ce18401062 100644
--- a/jstests/aggregation/explain_limit.js
+++ b/jstests/aggregation/explain_limit.js
@@ -18,7 +18,7 @@ let coll = db.explain_limit;
const kCollSize = 105;
const kLimit = 10;
-const isSBEEnabled = checkSBEEnabled(db);
+const isSBEEnabled = checkSBEEnabled(db, ["featureFlagSbeFull"]);
// Return whether or explain() was successful and contained the appropriate fields given the
// requested verbosity. Checks that the number of documents examined and returned are correct given
diff --git a/jstests/aggregation/optimize_away_pipeline.js b/jstests/aggregation/optimize_away_pipeline.js
index 453ee78db40..065691a0663 100644
--- a/jstests/aggregation/optimize_away_pipeline.js
+++ b/jstests/aggregation/optimize_away_pipeline.js
@@ -639,66 +639,33 @@ function assertProjectionIsNotRemoved(pipeline, projectionType = "PROJECTION_SIM
assertProjectionCanBeRemovedBeforeGroup(
[{$project: {a: 1, b: 1}}, {$group: {_id: "$a", s: {$sum: "$b"}}}]);
-// Test that an inclusion projection is NOT optimized away if it is NOT redundant. This one
-// fails to include a dependency of the $group and so will have an impact on the query results.
+assertProjectionCanBeRemovedBeforeGroup(
+ [{$project: {'a.b': 1, 'b.c': 1}}, {$group: {_id: "$a.b", s: {$sum: "$b.c"}}}],
+ "PROJECTION_DEFAULT");
+
+// Test that an inclusion projection is NOT optimized away if it is NOT redundant. This one fails to
+// include a dependency of the $group and so will have an impact on the query results.
assertProjectionIsNotRemoved([{$project: {a: 1}}, {$group: {_id: "$a", s: {$sum: "$b"}}}]);
+// Test similar cases with dotted paths.
+assertProjectionIsNotRemoved([{$project: {'a.b': 1}}, {$group: {_id: "$a.b", s: {$sum: "$b"}}}],
+ "PROJECTION_DEFAULT");
+assertProjectionIsNotRemoved([{$project: {'a.b': 1}}, {$group: {_id: "$a.b", s: {$sum: "$a.c"}}}],
+ "PROJECTION_DEFAULT");
// TODO SERVER-67323 This one could be removed, but is left for future work.
assertProjectionIsNotRemoved(
[{$project: {a: 1, b: 1}}, {$group: {_id: "$a.b", s: {$sum: "$b.c"}}}]);
-// If the $group depends on both "path" and "path.subpath" then it will generate a $project on only
-// "path" to express its dependency set. We then fail to optimize that out. As a future improvement,
-// we could improve the optimizer to ensure that a projection stage is not present in the resulting
-// plan.
+// Spinoff on the one above: Without supporting this kind of prefixing analysis, we can confuse
+// ourselves with our dependency analysis. If the $group depends on both "path" and "path.subpath"
+// then it will generate a $project on only "path" to express its dependency set. We then fail to
+// optimize that out.
pipeline = [{$group: {_id: "$a.b", s: {$first: "$a"}}}];
// TODO SERVER-XYZ Assert this can be optimized out.
// assertProjectionCanBeRemovedBeforeGroup(pipeline, "PROJECTION_DEFAULT");
// assertProjectionCanBeRemovedBeforeGroup(pipeline, "PROJECTION_SIMPLE");
assertProjectionIsNotRemoved(pipeline);
-// Though $group is generally eligible for pushdown into SBE, such a pushdown may be inhibited by
-// dotted as well as computed projections. As such we only run the test cases below if SBE is fully
-// enabled.
-const sbeFull = checkSBEEnabled(db, ["featureFlagSbeFull"], true /* checkAllNodes */);
-if (sbeFull) {
- assertProjectionCanBeRemovedBeforeGroup(
- [{$project: {'a.b': 1, 'b.c': 1}}, {$group: {_id: "$a.b", s: {$sum: "$b.c"}}}],
- "PROJECTION_DEFAULT");
-
- // Test that a computed projection at the front of the pipeline is pushed down, even if there's
- // no finite dependency set.
- pipeline = [{$project: {x: {$add: ["$a", 1]}}}];
- assertPipelineDoesNotUseAggregation(
- {pipeline: pipeline, expectedStages: ["COLLSCAN", "PROJECTION_DEFAULT"]});
-
- // The projections below are not removed because they fail to include the $group's dependencies.
- assertProjectionIsNotRemoved([{$project: {'a.b': 1}}, {$group: {_id: "$a.b", s: {$sum: "$b"}}}],
- "PROJECTION_DEFAULT");
- assertProjectionIsNotRemoved(
- [{$project: {'a.b': 1}}, {$group: {_id: "$a.b", s: {$sum: "$a.c"}}}], "PROJECTION_DEFAULT");
-
- pipeline = [{$project: {a: {$add: ["$a", 1]}}}, {$group: {_id: "$a", s: {$sum: "$b"}}}];
- assertPipelineIfGroupPushdown(
- // Test that a computed projection at the front of the pipeline is pushed down when there's
- // a finite dependency set. Additionally, the group pushdown shouldn't erase the computed
- // projection.
- function() {
- explain = coll.explain().aggregate(pipeline);
- assertPipelineDoesNotUseAggregation(
- {pipeline: pipeline, expectedStages: ["COLLSCAN", "PROJECTION_DEFAULT", "GROUP"]});
- },
- // Test that a computed projection at the front of the pipeline is pushed down when there's
- // a finite dependency set.
- function() {
- explain = coll.explain().aggregate(pipeline);
- assertPipelineUsesAggregation({
- pipeline: pipeline,
- expectedStages: ["COLLSCAN", "PROJECTION_DEFAULT", "$group"],
- });
- });
-}
-
// We generate a projection stage from dependency analysis, even if the pipeline begins with an
// exclusion projection.
pipeline = [{$project: {c: 0}}, {$group: {_id: "$a", b: {$sum: "$b"}}}];
@@ -729,6 +696,32 @@ pipeline = [{$project: {x: 0}}];
assertPipelineDoesNotUseAggregation(
{pipeline: pipeline, expectedStages: ["PROJECTION_SIMPLE", "COLLSCAN"]});
+// Test that a computed projection at the front of the pipeline is pushed down, even if there's no
+// finite dependency set.
+pipeline = [{$project: {x: {$add: ["$a", 1]}}}];
+assertPipelineDoesNotUseAggregation(
+ {pipeline: pipeline, expectedStages: ["COLLSCAN", "PROJECTION_DEFAULT"]});
+
+pipeline = [{$project: {a: {$add: ["$a", 1]}}}, {$group: {_id: "$a", s: {$sum: "$b"}}}];
+assertPipelineIfGroupPushdown(
+ // Test that a computed projection at the front of the pipeline is pushed down when there's a
+ // finite dependency set. Additionally, the group pushdown shouldn't erase the computed
+ // projection.
+ function() {
+ explain = coll.explain().aggregate(pipeline);
+ assertPipelineDoesNotUseAggregation(
+ {pipeline: pipeline, expectedStages: ["COLLSCAN", "PROJECTION_DEFAULT", "GROUP"]});
+ },
+ // Test that a computed projection at the front of the pipeline is pushed down when there's a
+ // finite dependency set.
+ function() {
+ explain = coll.explain().aggregate(pipeline);
+ assertPipelineUsesAggregation({
+ pipeline: pipeline,
+ expectedStages: ["COLLSCAN", "PROJECTION_DEFAULT", "$group"],
+ });
+ });
+
// getMore cases.
// Test getMore on a collection with an optimized away pipeline.