Unique Constraints on Arbitrary Fields & Migrations Collection?

Hi Kate,

If you are connected to a sharded cluster using the mongo shell, the prompt should change to mongos>. You can also check if a collection is sharded by calling db.collectionname.getShardDistribution(), which will report something like “Collection test.collectionname is not sharded.” for an unsharded collection.

Sharding is an approach for distributing data across multiple servers (or “shards”). Sharding is typically used to scale deployments with very large data sets and high throughput operations, but can also be useful for workload isolation (for example Segmenting Data by Location or Tiering Hardware for Varying SLA or SLO). Collections in a sharded cluster can be unsharded (the default) or sharded.

A sharded collection is partitioned based on a shard key index that you define based on one or more field values. Sharding enables horizontal scaling since each shard only has to manage a subset of the data for a sharded collection.

From an application point of view, a sharded collection is a single logical collection: you can query a sharded collection without being aware of which shard has the relevant results. However, since each shard only has a subset of the data enforcing uniqueness values other than the shard key requires some extra consideration (per the link you originally referenced).

If you are interested in learning more about MongoDB, there are free online courses available at MongoDB University and a few learning paths (Developer or DBA/Operations) with recommended courses to take.

Regards,
Stennie