⌘K
Flycodx

When to Shard & Choosing a Shard Key

When to Shard & Choosing a Shard Key

HardDatabases0% accepted

A single Postgres instance can no longer hold your write volume. Explain horizontal sharding, how to pick a shard key, and the pain it introduces. Cover: range vs hash sharding, hot-spot/celebrity problems from a bad key, cross-shard joins and transactions, and re-sharding cost.

Approach

Shard when one node can't handle the data/writes. Pick a key with high cardinality and even distribution (hash) to avoid hot shards. Cross-shard joins/transactions get hard; re-sharding is expensive — choose the key carefully.

Scenarios & Expected Answers

No example scenarios for this problem.

Sign in to continue

Create a free account to view answers and mark progress.

  • Free forever — no credit card
  • Theory Q&A with detailed answers
  • Points, streaks & leaderboards
Auto Save On