Skip to content

Commit 92c1340

Browse files
author
Sam Kleinman
committed
DOCS-443 edit to add shard key prefix example
1 parent 5232d96 commit 92c1340

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

source/core/sharding.txt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,28 @@ To route a query to a :term:`cluster <sharded cluster>`,
464464

465465
#. Determine the list of :term:`shards` that must receive the query.
466466

467-
In some cases, when the :term:`shard key` is a part of the query,
468-
the :program:`mongos` can route the query to a subset of the
469-
shards. Otherwise, the :program:`mongos` must direct the query to
470-
*all* shards.
467+
In some cases, when the :term:`shard key` or a prefix of the shard
468+
key is a part of the query, the :program:`mongos` can route the
469+
query to a subset of the shards. Otherwise, the :program:`mongos`
470+
must direct the query to *all* shards.
471+
472+
.. example::
473+
474+
Given the following shard key:
475+
476+
.. code-block:: javascript
477+
478+
{ zipcode: 1, u_id: 1, c_date: 1 }
479+
480+
Depending on the distribution of chunks in the cluster, the
481+
:program:`mongos` may be able to target the query at a subset of
482+
shards, if the query contains the following fields:
483+
484+
.. code-block:: javascript
485+
486+
{ zipcode: 1 }
487+
{ zipcode: 1, u_id: 1 }
488+
{ zipcode: 1, u_id: 1, c_date: 1 }
471489

472490
#. Establish a cursor on all targeted shards.
473491

0 commit comments

Comments
 (0)