Skip to content

Commit 87b412d

Browse files
jmd-mongoandf-mongodb
authored andcommitted
DOCSP-13710 monotonically changing shard keys
1 parent f1eac0a commit 87b412d

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

source/core/sharding-shard-key.txt

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ the cluster. See also :ref:`sharding strategy <sharding-strategy>`.
213213

214214
At minimum, consider the consequences of the
215215
:ref:`cardinality<shard-key-range>`, :ref:`frequency<shard-key-frequency>`, and
216-
rate of :ref:`change<shard-key-monotonic>` of a potential shard key.
216+
:ref:`monotonicity<shard-key-monotonic>` of a potential shard key.
217217

218218
.. note::
219219

@@ -269,11 +269,12 @@ inserts may look similar to the following:
269269
The cluster in this example would *not* scale horizontally, as incoming writes
270270
would only route to a subset of shards.
271271

272-
A shard key with high cardinality does not guarantee even distribution of data
273-
across the sharded cluster, though it does better facilitate horizontal
274-
scaling. The :ref:`frequency <shard-key-frequency>` and :ref:`rate of
275-
change <shard-key-monotonic>` of the shard key also contributes to data
276-
distribution. Consider each factor when choosing a shard key.
272+
Choosing a shard key with high cardinality does not, on its own,
273+
guarantee even distribution of data across the sharded cluster. The
274+
:ref:`frequency <shard-key-frequency>` and
275+
:ref:`monotonicity <shard-key-monotonic>` of the shard key also
276+
contribute to data distribution. Take each factor into account when
277+
choosing a shard key.
277278

278279
If your data model requires sharding on a key that has low cardinality,
279280
consider using a :term:`compound index` using a field that
@@ -298,19 +299,21 @@ distribution of inserts may look similar to the following:
298299

299300
.. include:: /images/sharded-cluster-ranged-distribution-frequency.rst
300301

301-
A shard key with low frequency does not guarantee even distribution of data
302-
across the sharded cluster. The :ref:`cardinality <shard-key-cardinality>` and
303-
:ref:`rate of change <shard-key-monotonic>` of the shard key also contributes
304-
to data distribution. Consider each factor when choosing a shard key.
302+
Choosing a shard key with low frequency does not, on its own, guarantee
303+
even distribution of data across the sharded cluster.
304+
The :ref:`cardinality <shard-key-cardinality>` and
305+
:ref:`monotonicity <shard-key-monotonic>` of the shard key also
306+
contribute to data distribution. Take each factor into account when
307+
choosing a shard key.
305308

306309
If your data model requires sharding on a key that has high frequency
307310
values, consider using a :term:`compound index` using a unique or
308311
low frequency value.
309312

310313
.. _shard-key-monotonic:
311314

312-
Monotonically Changing Shard Keys
313-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315+
Shard Key Monotonicity
316+
~~~~~~~~~~~~~~~~~~~~~~
314317

315318
A shard key on a value that increases or decreases monotonically is more
316319
likely to distribute inserts to a single shard within the cluster.
@@ -336,11 +339,12 @@ distribution of inserts may look similar to the following:
336339
If the shard key value was monotonically decreasing, then all inserts would
337340
route to ``Chunk A`` instead.
338341

339-
A shard key that does not change monotonically does not guarantee even
340-
distribution of data across the sharded cluster. The
341-
:ref:`cardinality<shard-key-cardinality>` and
342-
:ref:`frequency<shard-key-frequency>` of the shard key also contributes to
343-
data distribution. Consider each factor when choosing a shard key.
342+
Choosing a shard key that does not change monotonically does not, on
343+
its own, guarantee even distribution of data across the sharded cluster.
344+
The :ref:`cardinality<shard-key-cardinality>` and
345+
:ref:`frequency<shard-key-frequency>` of the shard key also contribute
346+
to data distribution. Take each factor into account when choosing a
347+
shard key.
344348

345349
If your data model requires sharding on a key that changes
346350
monotonically, consider using :doc:`/core/hashed-sharding`.

0 commit comments

Comments
 (0)