0

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" } );
5
  • Related to your previous question: What is the output of db.getSiblingDB('database').Collection.stats(1024*1024)? Commented Aug 2, 2023 at 13:55
  • The code is too long for stackoverflow, I uploaded it here codeshare.io/WdnegY Commented Aug 2, 2023 at 14:34
  • You need to show only the last 12 lines from stats(). Note, your command is sh.shardCollection("database.Collection" but you check "databse.Collection" - one a less! Commented Aug 2, 2023 at 16:39
  • I check the collection with command db.Collection.getShardDistribution(). The 12 last lines are: sharded: true, size: 10.072671890258789, count: 14180, numOrphanDocs: 0, storageSize: 2.1328125, totalIndexSize: 0.765625, totalSize: 2.8984375, indexSizes: { id: 0.578125, userId_1: 0.1875 }, avgObjSize: 744, ns: 'databse.Collection', nindexes: 2, scaleFactor: 1048576 Commented Aug 2, 2023 at 19:38
  • Please put such additional information in the question instead of a comment. Anyway the typo is obvious Commented Aug 3, 2023 at 5:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.