Docs Menu
Docs Home
MongoDB Manual
/ /

Modify Range Size in a Sharded Cluster

The default range size for a sharded cluster is 128 megabytes. This default range size works well for most deployments; however, if you notice that automatic migrations use more I/O than your hardware can handle, you may want to reduce the range size. A small range size leads to more rapid and frequent migrations. The allowed size is between 1 and 1024 megabytes, inclusive.

To modify the range size, use the following procedure:

  1. Connect to any mongos in the cluster using mongosh.

  2. Issue the following command to switch to the Config Database:

    use config
  3. Issue the following command to store the global range size configuration value:

    { _id: "chunksize" },
    { $set: { _id: "chunksize", value: <sizeInMB> } },
    { upsert: true }

Modifying the chunk size has several limitations:

  • Starting in MongoDB 6.0.3, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation. For details, see Balancing Policy Changes.

    Starting in MongoDB 6.0, the following auto-splitting commands do not perform an operation:

  • In MongoDB versions earlier than 6.0, automatic splitting only occurs for insert or update operations.

  • If you lower the chunk size, it may take time for all chunks to split to the new size.

  • Splits cannot be undone.

  • If you increase the chunk size, existing chunks grow only through insertion or updates until they reach the new size.

  • The allowed range of the chunk size is between 1 and 1024 megabytes, inclusive.

← Merge Chunks in a Sharded Cluster