summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorMaddie Zechar <mez2113@columbia.edu>2022-11-23 21:45:57 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-24 00:10:34 +0000
commitb75695e4e1d1b07c545f82ed31663dac248202cb (patch)
tree5f9bf6a6c311e37d653b920f2c0ca2f1c7496438 /src/mongo/db
parent71c42004e0e094a3b6efb3352f516af2b76eda3f (diff)
downloadmongo-b75695e4e1d1b07c545f82ed31663dac248202cb.tar.gz
SERVER-71529 Add serverStatus metric for classic and SBE plan cache size
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/query/classic_plan_cache.cpp1
-rw-r--r--src/mongo/db/query/plan_cache.h11
2 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/db/query/classic_plan_cache.cpp b/src/mongo/db/query/classic_plan_cache.cpp
index f4bbff1af2b..7789d894cb5 100644
--- a/src/mongo/db/query/classic_plan_cache.cpp
+++ b/src/mongo/db/query/classic_plan_cache.cpp
@@ -33,6 +33,7 @@
namespace mongo {
CounterMetric planCacheTotalSizeEstimateBytes("query.planCacheTotalSizeEstimateBytes");
+CounterMetric planCacheEntries("query.planCacheTotalQueryShapes");
std::ostream& operator<<(std::ostream& stream, const PlanCacheKey& key) {
stream << key.toString();
diff --git a/src/mongo/db/query/plan_cache.h b/src/mongo/db/query/plan_cache.h
index d950b93f52f..a7db20699f3 100644
--- a/src/mongo/db/query/plan_cache.h
+++ b/src/mongo/db/query/plan_cache.h
@@ -51,6 +51,12 @@ class PlanCacheEntryBase;
extern CounterMetric planCacheTotalSizeEstimateBytes;
/**
+ * Tracks the number of query shapes in the plan cache entries across all the collections. Each
+ * entry in the plan cache is a unique query shape.
+ */
+extern CounterMetric planCacheEntries;
+
+/**
* Information returned from a get(...) query.
*/
template <class CachedPlanType, class DebugInfoType>
@@ -103,7 +109,7 @@ public:
size_t works,
DebugInfoType debugInfo) {
// If the cumulative size of the plan caches is estimated to remain within a predefined
- // threshold, then then include additional debug info which is not strictly necessary for
+ // threshold, then include additional debug info which is not strictly necessary for
// the plan cache to be functional. Once the cumulative plan cache size exceeds this
// threshold, omit this debug info as a heuristic to prevent plan cache memory consumption
// from growing too large.
@@ -155,6 +161,7 @@ public:
~PlanCacheEntryBase() {
planCacheTotalSizeEstimateBytes.decrement(estimatedEntrySizeBytes);
+ planCacheEntries.decrement(1);
}
/**
@@ -258,6 +265,8 @@ private:
// Account for the object in the global metric for estimating the server's total plan cache
// memory consumption.
planCacheTotalSizeEstimateBytes.increment(estimatedEntrySizeBytes);
+ // Account for new entry in the plan cache.
+ planCacheEntries.increment(1);
}
// Ensure that PlanCacheEntryBase is non-copyable.