Advanced Database Partitioning 00:00:01 One shard runs hot under a balanced total Four shards hold twenty-seven hundred and fifty records. The busiest holds fifteen hundred. Predict what a median split changes and what must stay exactly the same. Shard 1 has 1,500 records and 85% load. It is a hot spot. 2,750 divided by 4 equals 687.5 on average. 1.5 times that is about 1,031, and 1,500 is above it. The average load is 40%. The median key cuts shard 1 into two halves of 750 records. Shard 5 is ready and empty. The map has not changed. Half of the records are copied, then the changes that arrive meanwhile. Load on shard 1 rises for a while. Map 9 is live. Two shards of 750 records at about 42% load. The total is still 2,750. The total record count survives the move. Balanced row counts only approximate balanced work, so inspect the new request rates and tail latency before declaring success. 00:01:18 Count through the slowest owner With no routing key, one global count has four partial answers. Follow the parallel requests and keep each subtotal visible until the coordinator can add them. Count the records. There is no shard key in the question. The coordinator asks all four at the same time. Each shard counts its own records. Answers come back: 1,500, 400, 350 and 500. The slowest decides when the next step starts. The coordinator adds them and replies. Fifteen hundred plus four hundred plus three hundred fifty plus five hundred equals twenty-seven hundred fifty. A complete count needs every response and a defined observation model for concurrent writes. 00:02:06 One celebrity post refuses to split Post forty-two draws nearly every like. Splitting its surrounding range moves neighbors away but leaves those increments aimed at one record. Can a cache absorb the writes? Post 42 lives on shard 1. Shard 1 is at its limit. Half of shard 1 moves away, and post 42 stays whole. The cache answers reads and refreshes once a second. Likes still hit shard 1. Likes go to 42#0 to 42#3, spread over the shards. The total needs all four pieces. A job adds them every second for the cache. Separate counter buckets can distribute increments. An exact total then requires reading a consistent combination of buckets, or the interface can publish a slightly delayed aggregate. 00:02:56 Ask with half a composite key A directory has three regions, each with two internal shards. Supply both pieces of the key, then remove one piece and trace the router's remaining choices. Three regions with two shards each. Both parts are known: one shard. All EU users: two shards. The region is unknown, so one shard in every region is asked: three. A question without either part asks all six. A region alone narrows the search to two shards here. The other key component alone selects one candidate per region because each region uses the same second-stage rule. 00:03:37 Why page one hundred and one gets expensive A four-shard catalog returns ten rows at a time in one stable order. Compare skipping one thousand rows with resuming after the last emitted sort key. Each shard sends its first 10 rows. 40 rows travel, 10 are kept. Rows 1,001 to 1,010. Each shard must send 1,010 rows. Each shard starts after the last key seen and sends 10. A cursor can go to the next page, not jump to page 500. Carry a unique tie-breaker in the cursor. Seek pagination makes sequential browsing cheaper, and a consistent snapshot or explicit change semantics determine what happens while the catalog changes.