Skip to content

DOCS-10517: Update unique key for sharded cluster #3197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions source/core/sharding-shard-key.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,20 @@ recreating an index on just the shard key.
Unique Indexes
~~~~~~~~~~~~~~

For a sharded collection, only the ``_id`` field index and the index on
the shard key or a :term:`compound index` where the shard key is a
:ref:`prefix <compound-index-prefix>` can be :doc:`unique
</core/index-unique>`:
For a sharded collection, only the index on the shard key or a :term:`compound
index` where the shard key is a :ref:`prefix <compound-index-prefix>` can be
:doc:`unique </core/index-unique>`:

- You cannot shard a collection that has unique indexes on other fields.

- You cannot create unique indexes on other fields for a sharded
collection.

.. important::

The ``_id`` field index can only be :doc:`unique </core/index-unique>`
across the sharded cluster if it is the shard key.

Through the use of the unique index on the shard key, MongoDB *can*
enforce uniqueness on the shard key values. MongoDB enforces uniqueness
on the *entire* key combination, and not individual components of the
Expand Down