Search DistillSys

Find a concept

Type at least two characters to search lessons, designs, papers, and interview prep.

Partitioningintermediate5 min read

Range Partitioning

Split ordered keyspace into contiguous ranges for efficient scans and controllable ownership.

2–5 minute refresher
Mental model

Sorted keys → range boundaries → one owner per range

30second
refresher
Range partitioning assigns contiguous slices of an ordered keyspace to shards. It makes range scans and locality efficient, while requiring the system to split, move, and route around changing boundaries.

What problem does it solve?

Hashing spreads load but destroys natural order. Workloads that scan time, geography, tenant IDs, or adjacent keys need placement that preserves locality.

How it works

  1. Choose an ordered partition key.
  2. Maintain a map from boundary ranges to shard owners.
  3. Route point queries to one range and scans to overlapping ranges.
  4. Measure size and traffic independently for every range.
  5. Split large or busy ranges and merge small neighbors.
Decision guide

Key trade-offs

ChoiceWhat you gainWhat it costs
Large rangesSmall routing mapCoarse balancing and hot spots
Small rangesFine-grained movementMore metadata and coordination
Time-leading keyEfficient recent scansWrite hotspot at the newest range
What happens if?

All writes target the latest timestamp

One terminal range becomes the sole write owner. Prefix with a controlled bucket, rotate ranges, or separate ingestion order from query order while preserving the scans the product needs.

Where it appears

  • Bigtable tablets
  • CockroachDB ranges
  • HBase regions
  • MongoDB range sharding
Senior interview modeWhen is range partitioning preferable to hash partitioning?Show answer
When ordered scans and data locality are primary access patterns and the system can actively split and balance skewed ranges.
#sharding#ranges#indexes#routing