The oldest way to split data is the one a printed encyclopedia uses. Volume 1 is A to Bo, volume 2 is Br to Ch, and so on. To find "Chennai" you don't search every volume. You look at the spines.
Partitioning by range works the same way. Each partition owns a continuous range of keys, and the keys inside a partition are kept in sorted order. That one property, sorted and continuous, makes some queries wonderfully cheap and makes one very common kind of key a disaster.
Range partitioning assigns each partition a continuous range of key values, so keys that sort next to each other are stored together.
How it works
Pick a partition key and split its possible values into ranges. Each range goes to one partition.
Say Tiffin stores each order's tracking history, keyed by order_id, and order IDs are numbers that go up over time:
| Partition | Key range | Machine |
|---|---|---|
| P1 | 1 to 25,000,000 | A |
| P2 | 25,000,001 to 50,000,000 | B |
| P3 | 50,000,001 to 75,000,000 | C |
| P4 | 75,000,001 and up | D |
To find order 31,400,227, the router checks the boundaries, sees it falls in P2, and sends the request to machine B. The map is tiny: just a list of boundaries.
The boundaries don't have to be evenly spaced. If keys are surnames, the range "A to B" might hold far more people than "X to Z". So the boundaries are set to split the data evenly, not the alphabet.