Docs Menu
Docs Home
/
MongoDB Manual
/ /

Change a Shard Key

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:

  • Jumbo chunks

  • Uneven load distribution

  • Decreased query performance over time

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.

Back

Choose a Shard Key