[DOCS-10112] Choosing a shard key should explain how only the first field in a compound shard key is used to select the shard for the data Created: 12/Apr/17  Updated: 30/Oct/23

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: James Reitz Assignee: Unassigned
Resolution: Won't Do Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 1 year, 14 weeks, 2 days ago
Epic Link: DOCSP-1769

 Description   

The documentation here https://docs.mongodb.com/manual/core/sharding-shard-key/#choosing-a-shard-key doesn't mention that when using a compound shard key, only the first field in the key is used to determine on what shard the data resides. Other fields are used to help improve cardinality, and spread data across chunks, but not across shards.

Since shard keys are immutable, this turns out to be a very important fact.



 Comments   
Comment by Education Bot [ 31/Oct/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Comment by James Reitz [ 25/Apr/17 ]

I'm now questioning if my understanding of how shard keys work to distribute documents across shards is accurate based on a recent experience where I saw two different chunks within a sharded collection with the same value for the first field in their shard key residing on different chunks. Regardless, it would be nice if the documentation described how range-based partitioning/sharding works.

Generated at Thu Feb 08 07:59:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.