New in version 8.0.
Starting in MongoDB 8.0, you can move an unsharded collection to a
different shard using the moveCollection command.
Use Cases
Moving unsharded collections to any shard can:
Optimize performance on larger, complex workloads.
Achieve better resource utilization.
More evenly distribute data across shards.
Consider the following scenarios:
A company runs an e-commerce platform with several unsharded collections, such as
products,orders, anduserson a single shard. Theorderscollection begins to grow significantly larger than the others, which causes performance issues on the shard. To improve performance and balance the load across the cluster, the administrator can use themoveCollectioncommand to move the smallerproductsanduserscollections to a different shard.A global application stores user data in three separate unsharded collections for users located in North America, Europe, and Asia on one shard. To reduce latency for users, an administrator can move these collections to a shard located in each respective region in the same cluster.
An application frequently performs
$lookupoperations between two unsharded collections,ordersandcustomers, that reside on different shards. To improve query performance, a database administrator can move both collections to the same shard.
Get Started
Access Control
To move unsharded collections on a deployment that enforces authentication, you
must authenticate as a user with at least the enableSharding role.