Command Palette

Search for a command to run...

PHASE 8Intermediate ~7 min· topic 2 of 10

Topic 8.2

Partitioning

In one line

Splitting one logical dataset into smaller slices so each slice can live (and be queried) on its own node.

0/10 · 0%

Think of it like this

Splitting one huge phone book into 26 smaller books, one for each starting letter. Each book is smaller and faster to search, but you need to know which book to open first.

Key ideas

  1. 01

    Partitioning = data independence: partitions are subsets of rows; each node owns some partitions.

  2. 02

    Range partitioning: partition by key ranges (dates, ids) — great for range queries, hot spots at the boundary.

  3. 03

    Hash partitioning: hash of key → partition — even distribution, but range queries become scatter-gather.

  4. 04

    List partitioning: by enumerated value (e.g. tenant/region).

  5. 05

    Partitions enable parallel query and independent failure/backup of slices.

  6. 06

    Pagination caveat: ORDER BY across partitions requires a merge step — cross-partition queries are slower.

Java / Spring map

  • →

    Postgres declarative partitioning; JPA transparent to it (you partition at the DB layer).

Code & diagrams

PartitioningStrategiesdiagram

Same table, three different ways to slice it — each with a different weak point.

Rendering diagram…

Explain without notes

01

Range vs hash partitioning for an events table — which has better write distribution, which reads better?

Practice

01

Partition the mock orders table by month (range) and by user-hash; compare hotspot behavior.

Trade-offs

  • ↔

    Hash kills range scans; range creates hot boundaries. The classic dial: choose by dominant access pattern.

Run it in production

Completion checklist

  • I can distinguish partitioning from sharding and pick the split key type.

Back to phase