summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@10gen.com>2016-09-14 14:45:45 -0400
committerJames Wahlin <james.wahlin@10gen.com>2016-09-16 17:04:42 -0400
commitf4600bb330c1ed7975fe4ec7562dbda40efb2d8f (patch)
treed77ae3ca43f798099cabbba370561e65e6dc3c0a /src/mongo
parentb767a1971e001b75b897eac5b4d0caef873b5eaa (diff)
downloadmongo-f4600bb330c1ed7975fe4ec7562dbda40efb2d8f.tar.gz
SERVER-25948 dbStats should indicate number of views
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/database.cpp10
-rw-r--r--src/mongo/db/commands/dbcommands.cpp1
-rw-r--r--src/mongo/s/commands/cluster_db_stats_cmd.cpp3
3 files changed, 9 insertions, 5 deletions
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp
index 005a4f23abf..85d3eab7f34 100644
--- a/src/mongo/db/catalog/database.cpp
+++ b/src/mongo/db/catalog/database.cpp
@@ -322,7 +322,8 @@ void Database::getStats(OperationContext* opCtx, BSONObjBuilder* output, double
list<string> collections;
_dbEntry->getCollectionNamespaces(&collections);
- long long ncollections = 0;
+ long long nCollections = 0;
+ long long nViews = 0;
long long objects = 0;
long long size = 0;
long long storageSize = 0;
@@ -337,7 +338,7 @@ void Database::getStats(OperationContext* opCtx, BSONObjBuilder* output, double
if (!collection)
continue;
- ncollections += 1;
+ nCollections += 1;
objects += collection->numRecords(opCtx);
size += collection->dataSize(opCtx);
@@ -349,7 +350,10 @@ void Database::getStats(OperationContext* opCtx, BSONObjBuilder* output, double
indexSize += collection->getIndexSize(opCtx);
}
- output->appendNumber("collections", ncollections);
+ getViewCatalog()->iterate(opCtx, [&](const ViewDefinition& view) { nViews += 1; });
+
+ output->appendNumber("collections", nCollections);
+ output->appendNumber("views", nViews);
output->appendNumber("objects", objects);
output->append("avgObjSize", objects == 0 ? 0 : double(size) / double(objects));
output->appendNumber("dataSize", size / scale);
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 9720775b0cf..f73166e42fa 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -1038,6 +1038,7 @@ public:
// is not needed for the missing DB case, we can just do the same that's done in
// CollectionStats.
result.appendNumber("collections", 0);
+ result.appendNumber("views", 0);
result.appendNumber("objects", 0);
result.append("avgObjSize", 0);
result.appendNumber("dataSize", 0);
diff --git a/src/mongo/s/commands/cluster_db_stats_cmd.cpp b/src/mongo/s/commands/cluster_db_stats_cmd.cpp
index 4661cac2b7b..1546fe4482e 100644
--- a/src/mongo/s/commands/cluster_db_stats_cmd.cpp
+++ b/src/mongo/s/commands/cluster_db_stats_cmd.cpp
@@ -83,8 +83,7 @@ public:
}
}
- // TODO: need to find a good way to get this
- // result.appendNumber( "collections" , ncollections );
+ // TODO SERVER-26110: Add aggregated 'collections' and 'views' metrics.
output.appendNumber("objects", objects);
// avgObjSize on mongod is not scaled based on the argument to db.stats(), so we use