Chunks are inclusive at the lower bound and exclusive at the upper bound.
However, find queries over a range of the form
{ $lt : X }where X is the upper bound of a chunk also targets the shard containing the chunk whose lower bound is X (at least according to find().explain()).
Note that a point query for X will only (and correctly) target the shard with the chunk whose lower bound is X.
Similarly, a query of the form
will (correctly) target the shard for both chunks.
This is undesirable both from a performance perspective, since an additional shard is unnecessarily targeted in this situation, and a testing perspective, since .explain() cannot be used to verify that all documents within a chunk's range lie only on the shard the chunk is expected to be on.
- is duplicated by
-
SERVER-5365 range query on shard key incorrectly sends query to extra shard(s)
- Closed
-
SERVER-38971 Single shard query hits multiple shard if it includes end of chunk range
- Closed
-
SERVER-51731 ChunkManager::getShardIdsForRange should not hardcode isMaxInclusive to true
- Closed
-
SERVER-4791 shard selection code ignores bound inclusivity
- Closed