mongodb looks at database and table sizes

  • 2020-05-07 20:37:12
  • OfStack

1. Check the database


> db.stats(); 
{ 
  "db" : "test",        // Current database  
  "collections" : 3,      // How many tables are in the current database  
  "objects" : 4,        // How many data are in all the tables in the current database  
  "avgObjSize" : 51,      // The average size of each piece of data  
  "dataSize" : 204,      // The total size of all the data  
  "storageSize" : 16384,    // The disk size of all the data  
  "numExtents" : 3, 
  "indexes" : 1,        // The index number  
  "indexSize" : 8176,     // Index size  
  "fileSize" : 201326592,   // The file size of the pre-allocated database  
  "nsSizeMB" : 16, 
  "dataFileVersion" : { 
    "major" : 4, 
    "minor" : 5 
  }, 
  "ok" : 1 
} 

2. View the database tables


> db.posts.stats(); 
{ 
  "ns" : "test.posts", 
  "count" : 1, 
  "size" : 56, 
  "avgObjSize" : 56, 
  "storageSize" : 8192, 
  "numExtents" : 1, 
  "nindexes" : 1, 
  "lastExtentSize" : 8192, 
  "paddingFactor" : 1, 
  "systemFlags" : 1, 
  "userFlags" : 0, 
  "totalIndexSize" : 8176, 
  "indexSizes" : { 
    "_id_" : 8176 
  }, 
  "ok" : 1 
} 


Related articles: