Get the storage size of a database in MongoDB?

MongoDBDatabaseBig Data Analytics

To get the storage size of a database in MongoDB, use the stats() method.

At first, check the current database with the help of the following query −

> db;

The following is the output −

test

Here is the query to get the storage size of the database in MongoDB −

> db.stats()

The following is the output displaying the stats including the storage size −

The following is the output −

{
   "db" : "test",
   "collections" : 114,
   "views" : 0,
   "objects" : 391,
   "avgObjSize" : 83.0076726342711,
   "dataSize" : 32456,
   "storageSize" : 3211264,
   "numExtents" : 0,
   "indexes" : 120,
   "indexSize" : 2494464,
   "fsUsedSize" : 126172377088,
   "fsTotalSize" : 199229435904,
   "ok" : 1
}
raja
Published on 28-Mar-2019 16:45:42
Advertisements