Change a Shard Key
This version of the documentation is archived and no longer supported. View the current documentation to learn how to upgrade your version of MongoDB server.
The ideal shard key allows MongoDB to distribute documents evenly throughout the cluster while facilitating common query patterns. A suboptimal shard key can lead to uneven data distribution and the following problems:
To address these issues, MongoDB allows you to change your shard key:
Starting in MongoDB 5.0, you can reshard a collection by changing a collection's shard key.
Starting in MongoDB 4.4, you can refine a shard key by adding a suffix field or fields to the existing shard key.
In MongoDB 4.2 and earlier, a document's shard key is immutable.
For more information on common performance and scaling issues and advice on how to fix them, read Troubleshoot Shard Keys.