Splitting By Order
Range sharding divides a table by contiguous spans of the primary key. Keys from A to M live on one shard, N to Z on another. Because keys stay in order, range queries touch few shards.
Strengths
- Range scans like a date interval read only the shards that cover that interval.
- Shards can split and merge automatically as data grows or shrinks.
- Ordered iteration and pagination are efficient.
The Hot Spot Risk
If new rows always have an increasing key, such as a timestamp or auto increment id, every insert lands on the last shard. That shard becomes a write hot spot while others sit idle. Mitigations include hashing a prefix of the key or splitting the busy range so its halves move to different nodes.
Key idea
Range sharding keeps keys ordered so scans stay cheap and shards rebalance by splitting, but monotonically increasing keys create write hot spots.