Grokking MongoDB
0% completed
Shard Keys
Shard a collection on a field with three distinct values, and the cluster can never divide the data into more than three useful parts. We tried this with a collection called bystatus, whose 20,000 documents hold a counter i and a status of pending, paid or shipped. After each value had its own chunk, MongoDB refused to divide further:
db.adminCommand({ split: "store.bystatus", find: { status: "paid" } }) // MongoServerError: Unable to find median in chunk because chunk is indivisible.
That limit stays as the collection grows, and every document with
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%