I created a mongodb cluster according to digitalocean's instructions. I sharded my database with the following command:
sh.shardCollection("database.Collection", {"userId": 1})
With the command
show dbs
I get the following output
database 24.84 GiB
With the command
db.Collection.getShardDistribution()
I get the following output
Shard shard2 at shard2/82.X.X.X:27017
{
data: '10.07MiB',
docs: 14180,
chunks: 1,
'estimated data per chunk': '10.07MiB',
'estimated docs per chunk': 14180
}
---
Totals
{
data: '10.07MiB',
docs: 14180,
chunks: 1,
'Shard shard2': [
'100 % data',
'100 % docs in cluster',
'744B avg obj size on shard'
]
}
Why are the sizes so different? I only have one collection.
The following command didn't change anything either
db.adminCommand( { flushRouterConfig: "databse.Collection" } );
db.getSiblingDB('database').Collection.stats(1024*1024)?stats(). Note, your command issh.shardCollection("database.Collection"but you check"databse.Collection"- onealess!