Olá,
Neste artigo irei demonstrar através de um script como obter informações de cada collection de um banco de dados, tais como quantidade de documentos, tamanho total real em MB e o tamanho total em MB ocupado em disco.
mongoPrdSet:PRIMARY> use bd01
switched to db bd01
mongoPrdSet:PRIMARY> cols.forEach(function(col) {
... {
... vstat=db.getCollection(col).stats({ scale : 1024*1024 }) //Em MB
... print(vstat.ns + " - count: " + vstat.count + " - size MB: " + vstat.size + " - storage_size MB: "+vstat.storageSize)
... }
... });
bd01.col01 - count: 2507 - size MB: 139 - storage_size MB: 53
bd01.col02 - count: 44372 - size MB: 2852 - storage_size MB: 600
bd01.col03 - count: 118476 - size MB: 710 - storage_size MB: 155
bd01.col04 - count: 3936 - size MB: 49 - storage_size MB: 16
bd01.col05 - count: 1797 - size MB: 12 - storage_size MB: 3
bd01.col06 - count: 2728 - size MB: 24 - storage_size MB: 5
bd01.col07 - count: 9406 - size MB: 73 - storage_size MB: 14
bd01.col08 - count: 57 - size MB: 32 - storage_size MB: 3
bd01.col09 - count: 1760 - size MB: 62 - storage_size MB: 14
bd01.col10 - count: 1616 - size MB: 38 - storage_size MB: 11
bd01.col11 - count: 1501 - size MB: 64 - storage_size MB: 18
bd01.col12 - count: 42880 - size MB: 4783 - storage_size MB: 1045
bd01.col13 - count: 2652 - size MB: 98 - storage_size MB: 28
bd01.col14 - count: 211 - size MB: 5 - storage_size MB: 1
bd01.col15 - count: 8055 - size MB: 5 - storage_size MB: 1
bd01.col16 - count: 225 - size MB: 14 - storage_size MB: 18
bd01.col17 - count: 309 - size MB: 7 - storage_size MB: 2
bd01.col18 - count: 7579 - size MB: 37 - storage_size MB: 11
bd01.col19 - count: 27762 - size MB: 135 - storage_size MB: 28
bd01.col20 - count: 26807 - size MB: 72 - storage_size MB: 12
Nenhum comentário:
Postar um comentário