Docs Menu

Docs HomeMongoDB Manual

Operational Restrictions in Sharded Clusters

On this page

  • Sharding Operational Restrictions

$where does not permit references to the db object from the $where function. This is uncommon in un-sharded collections.

The geoSearch command is not supported in sharded environments.

In MongoDB 5.0 and earlier, you cannot specify sharded collections in the from parameter of $lookup stages.

All updateOne() and deleteOne() operations for a sharded collection that specify the multi: false or justOne option must include the shard key or the _id field in the query specification.

updateOne() and deleteOne() operations specifying multi: false or justOne in a sharded collection which do not contain either the shard key or the _id field return an error.

To use findOneAndUpdate() with a sharded collection, your query filter must include an equality condition on the shard key to compare the key and value in either of these formats:

{ key: value }
{ key: { $eq: value } }

MongoDB does not support unique indexes across shards, except when the unique index contains the full shard key as a prefix of the index. In these situations MongoDB will enforce uniqueness across the full key, not a single field.



Unique Constraints on Arbitrary Fields for an alternate approach.

←  Sharding ReferenceTroubleshoot Sharded Clusters →
Share Feedback
© 2023 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.