The concept of the primary shard

So in the lecture Sharding Architecture it says a database may have a primary shard - does it mean database or mongod ?

So imagine I have 5 databases sat in a mongod instance e.g.

movies
applicationData
weather
etc

Now I have 3 shards in my sharded cluster 1 - 3. Could it in principle be

movies = Primary Shard 1
applicationData = Primary Shard 2
weather = Primary Shard 3

Hi NMullins,

The shards are not distributed among databases. Infact the data is distributed among shards and only that data which is huge and has sharding enabled on it. So if you have 5 databases but you enable sharding only on one database i.e movies and rest are same so it might look something like this:

Primary Shard 1 – chunks of movies database 0 --10000
Secondary Shard 2 – chunks of movies database 10000 - 20000
Secondary Shard 3 – chunks of movies database 20000-30000

If you need more information, you can always visit documentation: https://docs.mongodb.com/manual/sharding/

Kanika

Thank you, I thought that would be the case, but it is good to confirm.

To be honest, anything else wouldn’t have the granularity of control that would be required.

The online documents can be weighty tomes, and require a good amount of time to chew over :slight_smile: