• limited write volume, 

• expected data size, or 

• application query patterns. 

4. New in version 2.4: Use a hashed shard key . Choose a field that has high cardinality and create a hashed index (page 521) on that field. MongoDB uses these hashed index values as shard key values, which ensures an even distribution of documents across the shards. 

## Tip 

MongoDB automatically computes the hashes when resolving queries using hashed indexes. Applications do not need to compute hashes. 

## Considerations for Selecting Shard Key 

Choosing the correct shard key can have a great impact on the performance, capability, and functioning of your database and cluster. Appropriate shard key choice depends on the schema of your data and the way that your appli- cations query and write data. 

Create a Shard Key that is Easily Divisible An easily divisible shard key makes it easy for MongoDB to distribute content among the shards. Shard keys that have a limited number of possible values can result in chunks that are “unsplittable”. 

For instance, if a chunk represents a single shard key value, then MongoDB cannot split the chunk even when the chunk exceeds the size at which splits (page 687) occur. 

See also: 

Cardinality (page 696) 

Create a Shard Key that has High Degree of Randomness A shard key with high degree of randomness prevents any single shard from becoming a bottleneck and will distribute write operations among the cluster. 

See also: 

Write Scaling (page 675) 

Create a Shard Key that Targets a Single Shard A shard key that targets a single shard makes it possible for the mongos program to return most query operations directly from a single specific mongod instance. Your shard key should be the primary field used by your queries. Fields with a high degree of “randomness” make it difficult to target operations to specific shards. 

See also: 

Query Isolation (page 676) 

Shard Using a Compound Shard Key The challenge when selecting a shard key is that there is not always an obvious choice. Often, an existing field in your collection may not be the optimal key. In those situations, computing a special purpose shard key into an additional field or using a compound shard key may help produce one that is more ideal. 

