Moveable Collections
On this page
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
, andusers
on a single shard. Theorders
collection 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 themoveCollection
command to move the smallerproducts
andusers
collections 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
$lookup
operations between two unsharded collections,orders
andcustomers
, 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.