Key hash partitioning assigns records to horizontal partitions using a hash of their partitioning-key values. Records with the same key value go to the same partition. By spreading different key values across partitions, hashing can improve load balance and reduce hotspots and latency. section 5.2.1
Partitioning by location
If Location is the partition key, users in New York are placed together, while users in Sydney and Cape Town occupy their own partitions. The example illustrates how a logical table can be divided into horizontal partitions. section 5.2.1
Figure 5.1 Horizontally partitioning a database table. On the left, you can see the full logical table with four rows. On the right side, you can see three horizontal partitions.
Compare the logical table with its three horizontal partitions. section 5.2.1
Hashing does not guarantee balanced partition sizes. A low-cardinality key limits the number of distinct values available for distribution, and a skewed value can put many records together. For better balance, choose a high-cardinality key or combine columns to increase cardinality. Values can also differ in size: partitions holding larger images, for example, may be much larger even when key counts are equal. section 5.2.1 section 5.5.1
Choose the strategy for the access pattern and data distribution. Hashing ZIP codes can distribute unevenly populated areas better than partitioning by ZIP-code ranges. Range partitioning, however, supports range scans when keys are naturally ordered or have predictable ranges. Changing a poor partitioning scheme may require rebalancing every partition, which can be difficult on a live system. section 5.2.1 section 5.5.1
Routing a user-profile request
In a partition-aware HTTP client, a possible extension is to hash the user ID to select the node for a user-profile request. Request routing alone is not data partitioning: the client must implement a partitioning strategy to add it. section 5.6
