mongoDB

mongodb 에서 인덱스 용량 확인

freesunny 2024. 9. 21. 13:02
  • 해당 DB 의 컬렉션별 인덱스 용량을 각각 표시하는 방법
db.getCollectionNames().forEach(function(collection) {
  let stats = db[collection].stats();
  print(collection + " index size: " + (stats.totalIndexSize / (1024 * 1024)).toFixed(2) + " MB");
});

 

  • 해당 DB 의 컬력션별 인덱스 용량을 합산하여 표시하는 방법
let totalIndexSize = 0;
db.getCollectionNames().forEach(function(collection) {
  let stats = db[collection].stats();
  totalIndexSize += stats.totalIndexSize;
});
print("Total index size for all collections: " + (totalIndexSize / (1024 * 1024)).toFixed(2) + " MB");