Command "show dbs" from mongoshell in a sharded cluster

Hi guys

When I execute “show dbs” in mongoshell into a sharded cluster, the size of the database is the real data size (sum of each primary nodes) of the database or is it the size in all shard nodes?

Thanks

Hi @Oscar_Cervantes,

The show dbs shell command corresponds to the listDatabases admin command, which shows the size on disk for each database. The size for sharded collections is the sum of one member for each shard, and does not include redundant storage usage across all members of the shard replica set.

If you want to see more details than show dbs, try running the listDatabases command:

[direct: mongos] test> db.adminCommand({listDatabases:1, filter:{name:/test/}})
{
  databases: [
    {
      name: 'test',
      sizeOnDisk: 69632,
      empty: false,
      shards: { shard01: 57344, shard02: 12288 }
    }
  ],
  totalSize: 69632,
  totalSizeMb: 0,
  ok: 1,
  operationTime: Timestamp({ t: 1676495653, i: 1 }),
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1676495653, i: 1 }),
    signature: {
      hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
      keyId: Long("0")
    }
  }
}

Regards,
Stennie

5 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.