|
Regarding the root cause, I suspect what is happening is that all n candidate plans are added as children of the MultiPlanStage during the trial period via calls to MultiPlanStage::addPlan(). After the trial period completes and the winning plan is selected, the rejected candidates stay in place as children of the MultiPlanStage but are not executed any further. When yields occur, saveState()/restoreState() calls are propagated to the entire tree, including the lingering children of the MultiPlanStage corresponding to rejected plans. As a result, the rejected plans display the same yield count as the winning plan.
One way to fix this would be to deallocate the rejected plans after the trial period ends (though runtime modification of the plan tree might be undesirable). Another more invasive approach would be to change the architecture so that the multi-planner is not implemented as a PlanStage; this is the approach taken by the SBE engine and it is also suggested by SERVER-16894. A third possibility would be to change the explain code to capture the execution stats of the rejected plans immediately after the trial period ends, as opposed to waiting to capture these stats until the winning plan has finished running.
|