Navigation
This version of the documentation is archived and no longer supported.

sh.shardCollection()

sh.shardCollection(namespace, key, unique)
Parameters:
  • namespace (string) – The namespace of the collection to shard.
  • key (document) – A document containing a shard key that the sharding system uses to partition and distribute objects among the shards.
  • unique (boolean) – When true, the unique option ensures that the underlying index enforces uniqueness so long as the unique index is a prefix of the shard key.

Shards the named collection, according to the specified shard key. Specify shard keys in the form of a document. Shard keys may refer to a single document field, or more typically several document fields to form a “compound shard key.”

See

Size of Sharded Collection