获取MongoDB中所有集合的大小

 

 

 

https://blog.csdn.net/ruanjiana051/article/details/84588664?spm=1001.2101.3001.6650.6&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6-84588664-blog-104928526.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6-84588664-blog-104928526.pc_relevant_default&utm_relevant_index=8

 


 

 

var collNames = db.getCollectionNames();
for (var i = 0; i < collNames.length; i++) {  
    if (collNames[i].indexOf("不想要的表")> -1)continue;
  var coll = db.getCollection(collNames[i]); 
  var stats = coll.stats(1024 * 1024); 
  print("|name:",stats.ns,"|size:", stats.storageSize,"|count:",stats.count);
   
}

 

posted @ 2022-05-13 18:20  AngDH  阅读(619)  评论(0编辑  收藏  举报