diff options
author | samontea <merciers.merciers@gmail.com> | 2019-06-07 16:11:25 -0400 |
---|---|---|
committer | samontea <merciers.merciers@gmail.com> | 2019-07-10 16:29:06 -0400 |
commit | a4ef14ef41f0700ef07e5b57b0345d2396a44604 (patch) | |
tree | 9fe5a652acecb2b98cb09240b3fc90e47eb66452 /src/mongo/db/query | |
parent | 6bba6446e632b557ccc03834d4d48e90336679fc (diff) | |
download | mongo-a4ef14ef41f0700ef07e5b57b0345d2396a44604.tar.gz |
SERVER-40755 Expose statistics which indicate how many collection scans have executed
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r-- | src/mongo/db/query/explain.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/query/find.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/plan_summary_stats.h | 8 |
3 files changed, 17 insertions, 1 deletions
diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp index 709d8ffda4a..eb109928be4 100644 --- a/src/mongo/db/query/explain.cpp +++ b/src/mongo/db/query/explain.cpp @@ -34,6 +34,7 @@ #include "mongo/base/owned_pointer_vector.h" #include "mongo/bson/util/builder.h" #include "mongo/db/exec/cached_plan.h" +#include "mongo/db/exec/collection_scan.h" #include "mongo/db/exec/count_scan.h" #include "mongo/db/exec/distinct_scan.h" #include "mongo/db/exec/idhack.h" @@ -1015,6 +1016,13 @@ void Explain::getSummaryStats(const PlanExecutor& exec, PlanSummaryStats* statsO statsOut->replanned = cachedStats->replanned; } else if (STAGE_MULTI_PLAN == stages[i]->stageType()) { statsOut->fromMultiPlanner = true; + } else if (STAGE_COLLSCAN == stages[i]->stageType()) { + statsOut->collectionScans++; + const auto collScan = static_cast<const CollectionScan*>(stages[i]); + const auto collScanStats = + static_cast<const CollectionScanStats*>(collScan->getSpecificStats()); + if (!collScanStats->tailable) + statsOut->collectionScansNonTailable++; } } } diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index 8f4132b1eaf..f9de0152b5c 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -150,7 +150,7 @@ void endQueryOp(OperationContext* opCtx, curOp->debug().setPlanSummaryMetrics(summaryStats); if (collection) { - collection->infoCache()->notifyOfQuery(opCtx, summaryStats.indexesUsed); + collection->infoCache()->notifyOfQuery(opCtx, summaryStats); } if (curOp->shouldDBProfile()) { diff --git a/src/mongo/db/query/plan_summary_stats.h b/src/mongo/db/query/plan_summary_stats.h index 35deb4d83c0..a0ded1f2755 100644 --- a/src/mongo/db/query/plan_summary_stats.h +++ b/src/mongo/db/query/plan_summary_stats.h @@ -50,6 +50,14 @@ struct PlanSummaryStats { // The number of milliseconds spent inside the root stage's work() method. long long executionTimeMillis = 0; + // The number of collection scans that occur during execution. Note that more than one + // collection scan may happen during execution (e.g. for $lookup execution). + long long collectionScans = 0; + + // The number of collection scans that occur during execution which are nontailable. Note that + // more than one collection scan may happen during execution (e.g. for $lookup execution). + long long collectionScansNonTailable = 0; + // Did this plan use an in-memory sort stage? bool hasSortStage = false; |