diff options
author | joshua <80741223+jlap199@users.noreply.github.com> | 2021-11-15 20:36:24 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-15 21:50:04 +0000 |
commit | f72a3ac7a30c06ac470d137a44eb4a9281027728 (patch) | |
tree | 5bbefe1312f7c9a2637ee7093dc428d739106143 /src/mongo/db/query/plan_explainer_sbe.cpp | |
parent | 4dad7297741c91c8f8cd67e00ee39e6ec6789f7e (diff) | |
download | mongo-f72a3ac7a30c06ac470d137a44eb4a9281027728.tar.gz |
SERVER-59678 Avoid reconstructing PlanStageStats tree for replanning
Diffstat (limited to 'src/mongo/db/query/plan_explainer_sbe.cpp')
-rw-r--r-- | src/mongo/db/query/plan_explainer_sbe.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/mongo/db/query/plan_explainer_sbe.cpp b/src/mongo/db/query/plan_explainer_sbe.cpp index 1a6fff86019..20db0c44c32 100644 --- a/src/mongo/db/query/plan_explainer_sbe.cpp +++ b/src/mongo/db/query/plan_explainer_sbe.cpp @@ -33,11 +33,14 @@ #include <queue> +#include "mongo/db/exec/plan_stats_walker.h" #include "mongo/db/fts/fts_query_impl.h" #include "mongo/db/keypattern.h" #include "mongo/db/query/plan_explainer_impl.h" +#include "mongo/db/query/plan_summary_stats_visitor.h" #include "mongo/db/query/projection_ast_util.h" #include "mongo/db/query/query_knobs_gen.h" +#include "mongo/db/query/tree_walker.h" #include "mongo/db/record_id_helpers.h" namespace mongo { @@ -292,23 +295,9 @@ PlanSummaryStats collectExecutionStatsSummary(const sbe::PlanStageStats* stats) summary.executionTimeMillisEstimate = *stats->common.executionTimeMillis; } - // Collect cumulative execution stats for the plan. - std::queue<const sbe::PlanStageStats*> queue; - queue.push(stats); - while (!queue.empty()) { - stats = queue.front(); - invariant(stats); - queue.pop(); - - if (stats->specific) { - stats->specific->accumulate(summary); - } - - for (auto&& child : stats->children) { - queue.push(child.get()); - } - } - + auto visitor = PlanSummaryStatsVisitor(summary); + auto walker = PlanStageStatsWalker<true, sbe::CommonStats>(nullptr, nullptr, &visitor); + tree_walker::walk<true, sbe::PlanStageStats>(stats, &walker); return summary; } @@ -436,7 +425,8 @@ void PlanExplainerSBE::getSummaryStats(PlanSummaryStats* statsOut) const { statsOut->replanReason = _rootData->replanReason; // Collect cumulative execution stats for the plan. - _root->accumulate(kEmptyPlanNodeId, *statsOut); + auto visitor = PlanSummaryStatsVisitor(*statsOut); + _root->accumulate(kEmptyPlanNodeId, &visitor); std::queue<const QuerySolutionNode*> queue; queue.push(_solution->root()); |