Skip to content
Preptima
hardDesignSeniorStaffLead

How do you choose a datastore, and then how do you choose its shard key?

6 min readUpdated 2026-08-15

Answer

Short answer

Choose the store from the dominant access pattern and the invariants it must enforce, not from a category label. Choose the shard key so the most frequent query is answerable from one shard, the key has enough distinct high-traffic values to spread load, and shards can be split later without rewriting every row.

Was this answer helpful?

Likely follow-ups

  • Your shard key is tenant id and one tenant is 40% of the workload. What do you change?
  • How do you run a query that needs a global ordering across all shards?
  • Walk me through migrating from 8 shards to 12 while serving traffic.
  • What breaks first when a transaction needs to span two shards, and what would you do instead?

Related questions

Further reading