Try
↑ ↓ move↵ openesc close

Partitioning keys lab

Spread keys over partitions by key range or by hash, under uniform, skewed and sequential traffic. See hot partitions, the cost of a range scan, and what splitting a hot range does.

Skewed (Zipf) keysbusiest ÷ mean = 6.42Range partitioning, loads counted since the last split

Cuts it at the key where half its load lies below. Splits so far: 0.

Range partitioning · 8 partitions

busiest vs mean
6.42x
busiest share
80%
partitions per scan
1.2

Even would be 12.5% each.

Busiest partition against the mean
Busiest partition against the mean. Text version available below the chart.1.03.35.57.810.04 ticks32 ticks60 ticksticks runbusiest ÷ mean

What to try

Each one sets up a starting point. Then make the change it describes.

  1. Uniform traffic, either way works

    Pick Compare all partitionings with uniform keys.

    Look for. Both layouts spread requests evenly. When traffic is uniform, the choice is about scans and splits, not balance.

  2. Timestamps pile onto one partition

    Pick sequential keys and compare both layouts. Watch which range partition takes the load.

    Look for. Every new key is larger than all existing ones, so range partitioning sends all of it to the last partition. Hashing scatters the same keys evenly.

  3. Hash is not a cure for a hot key

    Compare both layouts with skewed traffic, then raise the skew from 1.0 to 1.4.

    Look for. Hashing spreads the popular keys over many partitions, but the single most popular key still lands on one of them, so that partition stays hot. Higher skew makes it worse.

  4. What hashing costs: range scans

    Compare both layouts with uniform keys and 300 keys per scan, then raise the scan to 2000 keys.

    Look for. A range scan reads neighbouring keys. Range partitioning keeps them together, so a scan touches one or two partitions. Hashing scatters them, so nearly every partition is involved.

  5. Split the hot range

    Use range partitioning with skewed traffic and press Split the busiest range partition several times, pausing between presses.

    Look for. Each split moves half the hot partition load to a new partition and the busiest share falls. Splits stop helping once the hottest partition is one key. With sequential keys, splitting does not help at all, because the next keys still arrive at the end.

New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms