Greetings. I was practicing sharding of databases and noticed something that, according to my understanding, should work different.
I want to shard a collection, using ranged sharding. Shard key looks like this {sk: 1, ts: 1}
, where sk is a hashed field, and ts is a timestamp.
I create some tags and shard this collection on two shard servers. Everything looks as expected.
When i create documents, they are placed exactly where i want them. But then i decided to check queries and saw something unexpected. When i run db.collection.find({sk: 1}), db.collection.find({sk: 2}) or db.collection.find({sk: 3})
, the querries are going to one of the shards. When i run db.collection.find({sk: 2})
, the querry is going to both shards. The question is, isn’t it supposed to go to the second shard only, since 2 is an exclusive max boundary for the first shard?
Thank you for your time. Sorry, if it is something obvious or was discussed before.