diff options
author | samontea <merciers.merciers@gmail.com> | 2019-05-31 14:05:37 -0400 |
---|---|---|
committer | samontea <merciers.merciers@gmail.com> | 2019-07-10 16:07:42 -0400 |
commit | 6bba6446e632b557ccc03834d4d48e90336679fc (patch) | |
tree | 8f550393c99b15f4b27d9bbb27115fc451930be7 /src/mongo/db/query/plan_ranker.h | |
parent | 0434f018920206c197ab06b96e1a74dcbdf8885a (diff) | |
download | mongo-6bba6446e632b557ccc03834d4d48e90336679fc.tar.gz |
SERVER-41279 Eliminate failed plans from consideration during query planning
Diffstat (limited to 'src/mongo/db/query/plan_ranker.h')
-rw-r--r-- | src/mongo/db/query/plan_ranker.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/mongo/db/query/plan_ranker.h b/src/mongo/db/query/plan_ranker.h index 20c64e35b82..bb194c69f5f 100644 --- a/src/mongo/db/query/plan_ranker.h +++ b/src/mongo/db/query/plan_ranker.h @@ -50,13 +50,14 @@ struct PlanRankingDecision; class PlanRanker { public: /** - * Returns index in 'candidates' of which plan is best. - * Populates 'why' with information relevant to how each plan fared in the ranking process. - * Caller owns pointers in 'why'. - * 'candidateOrder' holds indices into candidates ordered by score (winner in first element). + * Returns a PlanRankingDecision which has the ranking and the information about the ranking + * process with status OK if everything worked. 'candidateOrder' within the PlanRankingDecision + * holds indices into candidates ordered by score (winner in first element). + * + * Returns an error if there was an issue with plan ranking (e.g. there was no viable plan). */ - static size_t pickBestPlan(const std::vector<CandidatePlan>& candidates, - PlanRankingDecision* why); + static StatusWith<std::unique_ptr<PlanRankingDecision>> pickBestPlan( + const std::vector<CandidatePlan>& candidates); /** * Assign the stats tree a 'goodness' score. The higher the score, the better @@ -102,6 +103,7 @@ struct PlanRankingDecision { } decision->scores = scores; decision->candidateOrder = candidateOrder; + decision->failedCandidates = failedCandidates; return decision; } @@ -119,8 +121,15 @@ struct PlanRankingDecision { // with corresponding cores[0] and stats[0]. Runner-up would be // candidates[candidateOrder[1]] followed by // candidates[candidateOrder[2]], ... + // + // Contains only non-failing plans. std::vector<size_t> candidateOrder; + // Contains the list of original plans that failed. + // + // Like 'candidateOrder', the contents of this array are indicies into the 'candidates' array. + std::vector<size_t> failedCandidates; + // Whether two plans tied for the win. // // Reading this flag is the only reliable way for callers to determine if there was a tie, |