-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Blocker - P1
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
If a $match has a top-level $and with $or children, it takes a long time to estimate, enough to trigger a "slow query" log event.
perf reports the following:
... + 99.47% 0.00% conn9 mongod_with_debug [.] mongo::(anonymous namespace)::RunCommandImpl::run() ▒ + 99.47% 0.00% conn9 mongod_with_debug [.] mongo::CommandHelpers::runCommandInvocation(mongo::OperationContext*, mongo::CommandInvocation*, mongo::rpc::ReplyBuilderInterface*) ▒ + 99.47% 0.00% conn9 mongod_with_debug [.] mongo::(anonymous namespace)::PipelineCommand::Invocation::explain(mongo::OperationContext*, mongo::explain::VerbosityEnum, mongo::rpc::ReplyBui▒ + 99.47% 0.00% conn9 mongod_with_debug [.] mongo::runAggregate(mongo::OperationContext*, mongo::AggregateCommandRequest&, mongo::LiteParsedPipeline const&, mongo::BSONObj const&, std::vec▒ + 99.47% 0.00% conn9 mongod_with_debug [.] mongo::(anonymous namespace)::_runAggregate(mongo::AggExState&, mongo::rpc::ReplyBuilderInterface*) ▒ + 91.39% 3.57% conn9 mongod_with_debug [.] mongo::exec::matcher::MatchExpressionEvaluator::visit(mongo::AndMatchExpression const*) ▒ + 87.50% 8.37% conn9 mongod_with_debug [.] mongo::exec::matcher::MatchExpressionEvaluator::visit(mongo::OrMatchExpression const*) ▒ + 80.54% 0.00% conn9 mongod_with_debug [.] mongo::PipelineD::buildInnerQueryExecutor(mongo::MultipleCollectionAccessor const&, mongo::NamespaceString const&, mongo::AggregateCommandReques▒ + 80.54% 0.00% conn9 mongod_with_debug [.] mongo::PipelineD::buildInnerQueryExecutorGeneric(mongo::MultipleCollectionAccessor const&, mongo::NamespaceString const&, mongo::AggregateComman▒ + 80.52% 0.00% conn9 mongod_with_debug [.] mongo::(anonymous namespace)::prepareExecutor(boost::intrusive_ptr<mongo::ExpressionContext> const&, mongo::MultipleCollectionAccessor const&, m▒ + 80.52% 0.00% conn9 mongod_with_debug [.] mongo::getExecutorFind(mongo::OperationContext*, mongo::MultipleCollectionAccessor const&, std::unique_ptr<mongo::CanonicalQuery, std::default_d▒ + 80.52% 0.00% conn9 mongod_with_debug [.] mongo::getExecutorFind(mongo::OperationContext*, mongo::MultipleCollectionAccessor const&, std::unique_ptr<mongo::CanonicalQuery, std::default_d▒ + 80.52% 0.00% conn9 mongod_with_debug [.] mongo::(anonymous namespace)::PrepareExecutionHelper<mongo::PlanCacheKey, mongo::(anonymous namespace)::ClassicRuntimePlannerResult>::prepare() ▒ + 80.51% 0.00% conn9 mongod_with_debug [.] mongo::QueryPlanner::planWithCostBasedRanking(mongo::CanonicalQuery const&, mongo::QueryPlannerParams const&, mongo::ce::SamplingEstimator*, mon▒ + 78.87% 0.00% conn9 mongod_with_debug [.] mongo::cost_based_ranker::CardinalityEstimator::estimate(mongo::QuerySolutionNode const*) ▒ + 78.87% 0.00% conn9 mongod_with_debug [.] mongo::cost_based_ranker::CardinalityEstimator::passThroughNodeCard(mongo::QuerySolutionNode const*) ▒ + 78.87% 0.00% conn9 mongod_with_debug [.] mongo::cost_based_ranker::CardinalityEstimator::estimate(mongo::FetchNode const*) ▒ + 78.86% 0.00% conn9 mongod_with_debug [.] mongo::cost_based_ranker::CardinalityEstimator::estimate(mongo::FetchNode const*)::$_1::operator()() const ▒ + 78.79% 8.05% conn9 mongod_with_debug [.] mongo::exec::matcher::MatchExpressionEvaluator::visitPathExpression(mongo::PathMatchExpression const*) ▒ + 73.00% 0.00% conn9 mongod_with_debug [.] mongo::ce::SamplingEstimatorImpl::estimateCardinality(mongo::MatchExpression const*) const ▒ + 27.54% 21.03% conn9 mongod_with_debug [.] mongo::getFieldDottedOrArray(mongo::BSONObj const&, mongo::FieldRef const&, unsigned long*, unsigned long) ▒ + 26.44% 1.00% conn9 mongod_with_debug [.] mongo::BSONMatchableDocument::allocateIterator(mongo::ElementPath const*) const ▒ + 25.44% 1.06% conn9 mongod_with_debug [.] mongo::BSONElementIterator::reset(mongo::ElementPath const*, mongo::BSONObj const&) ▒ + 18.93% 0.00% conn9 mongod_with_debug [.] mongo::Explain::explainStages(mongo::PlanExecutor*, mongo::MultipleCollectionAccessor const&, mongo::explain::VerbosityEnum, mongo::BSONObj, mon▒ + 18.88% 0.00% conn9 mongod_with_debug [.] mongo::PlanExecutorImpl::getNextBatch(unsigned long, std::function<bool (mongo::BSONObj const&, mongo::BSONObj const&, unsigned long)>) ▒ + 18.84% 0.01% conn9 mongod_with_debug [.] mongo::PlanStage::work(unsigned long*) ▒ + 18.83% 0.00% conn9 mongod_with_debug [.] mongo::ProjectionStage::doWork(unsigned long*) ▒ + 18.80% 0.01% conn9 mongod_with_debug [.] mongo::FetchStage::doWork(unsigned long*) ▒ + 18.71% 0.00% conn9 mongod_with_debug [.] mongo::Filter::passes(mongo::WorkingSetMember*, mongo::MatchExpression const*) ▒ + 15.41% 8.25% conn9 mongod_with_debug [.] mongo::BSONElementIterator::more() ...
This is scenario DatasetOneFieldIndex.WorkloadAndPlusOrOverSingleField from jstests/product_limits/query_limits_test.js . Please reach out to me if you have trouble reproducing.
- is related to
-
SERVER-112930 [QUERY_LIMITS] Slow estimation of $all with many arguments
-
- Needs Scheduling
-