Create Ranges in a Sharded Cluster
On this page
In most situations a sharded cluster will create, split, and distribute ranges automatically without user intervention. However, in some cases, MongoDB cannot create enough ranges or distribute data fast enough to support the required throughput.
For example, if you want to ingest a large volume of data into a cluster where you have inserts distributed across shards, pre-splitting the ranges of an empty sharded collection can improve throughput.
Note
Starting in MongoDB 6.0, the balancer does not distribute empty
ranges. To pre-split the collection, use moveRange
to
distribute the empty ranges across the shards in the cluster.
moveRange
automatically splits the range to be moved, meaning
moveRange
performs both splitting and moving. You don't need to
manually split the range with split
.
Alternatively, by defining the zones and zone ranges before sharding an empty or a non-existing collection, the shard collection operation creates ranges for the defined zone ranges as well as any additional ranges to cover the entire range of the shard key values and performs an initial range distribution based on the zone ranges. For more information, see Empty Collection.
Warning
Only pre-split ranges for an empty collection. Manually splitting ranges for a populated collection can lead to unpredictable range ranges and sizes as well as inefficient or ineffective balancing behavior.
Learn More
Initial ranges created and distributed by the sharding command, see Empty Collection.
Balancer and automatic distribution of ranges across shards, see Balancer Internals and Range Migration.
Manually migrate ranges, see Migrate Ranges in a Sharded Cluster.