The shard key (https://docs.mongodb.com/manual/sharding/#shard-keys) is a document field (or fields) within the collection which forms the basis upon which MongoDB will distribute documents between the shards. This field (or fields) must be immutable (it cannot be changed once the document is saved), and must exist in every single document in the collection to be sharded. A collection can only have one shard key, and once chosen, cannot be changed. If no index for the shard key field exists, one is created automatically. The shard key is then used to determine how the chunks are created, which are then distributed across the shards.
Shard keys are chosen based on the following criteria:
- Cardinality (https://en.wikipedia.org/wiki/Cardinality ...