<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Change a Shard Key
  <a class="headerlink leafygreen-ui-1kepx47" href="#change-a-shard-key" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="change-a-shard-key">
   </div>
  </a>
 </h1>
 <p class="leafygreen-ui-1kp3ins">
  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:
 </p>
 <ul class="leafygreen-ui-rioki0">
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-troubleshooting-shard-keys/#std-label-sharding-troubleshooting-jumbo-chunks">
     Jumbo chunks
    </a>
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-troubleshooting-shard-keys/#std-label-sharding-troubleshooting-monotonicity">
     Uneven load distribution
    </a>
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-troubleshooting-shard-keys/#std-label-sharding-troubleshooting-scatter-gather">
     Decreased query performance over time
    </a>
   </p>
  </li>
 </ul>
 <p class="leafygreen-ui-1kp3ins">
  To address these issues, MongoDB allows you to change your shard key:
 </p>
 <ul class="leafygreen-ui-rioki0">
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    Starting in MongoDB 5.0, you can
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-reshard-a-collection/#std-label-sharding-resharding">
     reshard a collection
    </a>
    by changing a collection's shard key.
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    You can
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-refine-a-shard-key/#std-label-shard-key-refine">
     refine a shard key
    </a>
    by adding a suffix field
or fields to the existing shard key.
   </p>
  </li>
 </ul>
 <p class="leafygreen-ui-1kp3ins">
  Data distribution fixes are most effective when you
reshard a collection. If you want to improve data distribution and your
cluster meets the
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-reshard-a-collection/#std-label-reshard-requirements">
   criteria to reshard
  </a>
  ,
you should reshard the collection instead of refining the shard key. If
your cluster doesn't meet the criteria to reshard, you should
refine the shard key.
 </p>
 <p class="leafygreen-ui-1kp3ins">
  For more information on common performance and scaling issues and advice
on how to fix them, read
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/sharding-troubleshooting-shard-keys/#std-label-shardkey-troubleshoot-shard-keys">
   Troubleshoot Shard Keys
   <!-- -->
   .
  </a>
 </p>
</section>
