summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/sbe_stage_builder_filter.cpp
diff options
context:
space:
mode:
authorIan Boros <ian.boros@mongodb.com>2021-05-27 17:08:35 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-01 17:42:46 +0000
commit90eb445e58124ed8b6b46a048834bffe350dad4c (patch)
treecc24fb680e254f1e4eff5946b51b7b924af8d561 /src/mongo/db/query/sbe_stage_builder_filter.cpp
parentabda02c1aa43b6ce053eb8857d1724dceee43fd2 (diff)
downloadmongo-90eb445e58124ed8b6b46a048834bffe350dad4c.tar.gz
SERVER-57225 Prevent top-level AND optimization from being used for ANDs with many children
Diffstat (limited to 'src/mongo/db/query/sbe_stage_builder_filter.cpp')
-rw-r--r--src/mongo/db/query/sbe_stage_builder_filter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/query/sbe_stage_builder_filter.cpp b/src/mongo/db/query/sbe_stage_builder_filter.cpp
index 0cdccc4323a..cedb52a3f5b 100644
--- a/src/mongo/db/query/sbe_stage_builder_filter.cpp
+++ b/src/mongo/db/query/sbe_stage_builder_filter.cpp
@@ -80,6 +80,7 @@ namespace mongo::stage_builder {
namespace {
struct MatchExpressionVisitorContext;
+const size_t kMaxChildrenForTopLevelAndOptimization = 25;
/**
* Output of the tree can come from two places:
@@ -131,7 +132,8 @@ struct MatchExpressionVisitorContext {
// If the root node is an $and, store it in 'topLevelAnd'.
// TODO: SERVER-50673: Revisit how we implement the top-level $and optimization.
- if (root->matchType() == MatchExpression::AND) {
+ if (root->matchType() == MatchExpression::AND &&
+ root->numChildren() <= kMaxChildrenForTopLevelAndOptimization) {
topLevelAnd = root;
}
}
@@ -165,7 +167,8 @@ struct MatchExpressionVisitorContext {
// If the root node is an $and, store it in 'topLevelAnd'.
// TODO: SERVER-50673: Revisit how we implement the top-level $and optimization.
- if (root->matchType() == MatchExpression::AND) {
+ if (root->matchType() == MatchExpression::AND &&
+ root->numChildren() <= kMaxChildrenForTopLevelAndOptimization) {
topLevelAnd = root;
}
}