~learn.
0:00 / 1:10
W01 · Data at scale

A perfect load spread, and a useless partition key

transcript

Your load is perfectly even across every partition. And loading one user's data now hits all of them.

A junior engineer wants to spread the load. Hash the user ID plus the timestamp. Every event gets a different hash. So they scatter everywhere. The spread is excellent. Not one hot partition.

But here's the catch. Fetch everything for user 123. Which partition? You'd need every timestamp to know. So you ask every partition. That's a random partition key, in disguise.

So what were they really after? No hot spots from very active users. Fair worry. Wrong fix. They broke every practical query to fix a few users.

The fix. Partition by user ID alone. One user, one partition. The timestamp becomes the sort key, inside that partition. Worried about a few heavy users? Salt only those, across 10 partitions.

An even spread isn't the goal. Fast queries are. If you always ask by user, partition by user.

Full breakdown in the lecture.