Database Partitioning Strategies 00:00:01 The first number across the fence A warehouse allocates increasing parcel numbers. Give each shard one contiguous range and send number one thousand to the router. Which side owns the boundary? 42 is below 1000, so it belongs to shard 0. 1500 is between 1000 and 1999: shard 1. Exactly on the bound. The lower bound is included, so it is shard 1. New ids are 2001, 2002, 2003. Shard 2 takes every write. Write the inclusive lower bound directly into the routing rule. Range scans benefit from neighboring records living together, while the highest range must absorb new sequential parcels. 00:00:46 Neighbors stop traveling together Route the same parcels by their remainder on division by three. Predict whether three consecutive numbers still land together, then send a burst of requests for parcel forty-two. 42 mod 3 is 0. The neighbour goes somewhere else. 2001, 2002 and 2003 go to three different shards. Growing keys do not hurt. Key 42 gets most of the traffic. It always lands on shard 0. Hashing can distribute many distinct keys across owners. Every lookup for one hot parcel still converges on its owner, so traffic measurements matter alongside the row counts. 00:01:26 Give a region its own entry Some warehouse contracts prescribe a region's placement. Keep an explicit region table and move one region while preserving the assignments for the other customers. The table says shard 0. LATAM shares shard 2 with ASIA. Not in the table, so the router refuses. Its rows are copied to a new shard first. The map still says shard 2. Map 13 sends LATAM to shard 3. Nobody else is affected. Copy the data and reconcile intervening writes before switching the map. Define what the router does for an unknown region so missing configuration cannot silently misplace orders. 00:02:04 Ask for a slice of parcel numbers A supervisor requests numbers nine hundred through eleven hundred. Trace which routes can exclude a shard before anyone opens a record. 900 is on shard 0. 1100 is on shard 1. Shard 2 is skipped. Matching ids are scattered, so all three are asked. The list knows regions, not ids. Without a region all shards are asked. Routing information only helps for predicates it can interpret. A region table alone cannot infer where a numeric interval lives when the request omits the region. 00:02:37 Order messages inside one channel A chat history request supplies a channel and a time interval. Give the channel a hash-based home, then order its messages by time inside that home. Each channel has one shard, chosen by its hash. Inside a channel, messages are in time order. One shard, and the newest rows are at the end. Add a time bucket to the first part, such as channel and month, so that no partition grows for ever. A busy channel can outgrow one partition despite excellent distribution across ordinary channels. A time bucket bounds each partition and may turn a long history into several reads.