Understanding Explain for Sharded Clusters : people collection is shared on one shard only

Hi Everybody,

Hi @007_jb

I’m facing the same issue as Kyle, below the discussion link you have made with it

People collection is distributed on only one shared :

  1. I deleted dbPath and restarted mongod, then I build again sharded cluster with mtools and import
    people collection
    ==> Same issue

  2. I tried sharding collection using last_name index.
    ==> same issue

I just don’t understand why data are not distributed on both shared cluster even if the sh.status indicate that shard 1 and shard 2 are correctly configured and each one has his chunks

Thanks for help


Here is the out

What is the output of sh.status()
Did you create the index?
Please show output of db.adminCommand( { shardCollection…

Did you try with sku field?

Hello @Ramachandra_37567
Thanks for your replay,
Below the different outputs of sh.status / db.people.getShardDistribution() /db.adminCommand … using index on _id field (first case) and using index on sku field (second case)
I get an error when executing db.adminCommand({shardCollection : …
Maybe I tap a wrong query, can you check it please

First case : Index on _Id field :



db.adminCommand({shardCollection : “m201.people”, key :{shardKey :"_id"} })

Second case : Index on sku field

Ceating index on sku field :

Sharding people collection:

After importing data set, sh.status() :

db.people.getShardDistribution() :

db.adminCommand({shardCollection : “m201.people”, key :{shardKey :“sku”} }) :

best regards


Are you sure the name of the collection is people?

I do not think that sku makes sense for people. As far as I remember the collection is called products. Can you share the exact name of the lab you are doing? We cannot compare with the requirements if we do not know exactly what you are try complete.

Hello @steevej-1495

Thanks for your answer,

It’s not a lab, I’m trying to complete a course video from mongodb Performance course
Chapter 2 : Mongodb Indexes ==> Video 6 Understanding Explain for Sharded Clusters.
You are right sku doesn’t makes a sens for people, ssn field does.

I’m building 2 shards by mlaunch from mtools, after charding people collection, data are distributed on only 1 shard, I can’t have same results like video in which data are distributed on 2 shards.

Creating index on ssn field, sharding the collection again, importing data, but same issue.

sh.status() output :

db.people.getShardDistribution() output :

Best Regards

Please check the syntax of shardCollection
Should be something like this

db.adminCommand( { shardCollection: “m103.products”, key: { “sku”: 1 } } )
Modify above to suit your DB/collection

Hello @Ramachandra_37567

Thanks for correction,
here is the output of db.adminCommand …

Hi Everybody,

Hi @steevej-1495. Hi @Ramachandra_37567

any help please, I think that i will be blocked for the next lessons if I dont resolve this issue

Thank you


The db.adminCommand did not give any error now
I thought issue got resolved
What is the output of sh.status()

I have the same issue, no distribution on 2 shards :

Here is the output if sh.status()

I think the data is too small and it is going into one chunk
Try with a bigger collection like products as steevej-1495 mentioned

Try to concentrate on your labs.Replicating what shown in lectures may or may not work as they may be using different dataset/size

@Ramachandra_37567, @steevej-1495

With products collection, data distribution is ok on both shards, I used sku index,
you are right it’s because data size of people collection, many thanks,