Choosing the shard key
A rule decides which shard owns a row. A multi-tenant SaaS might shard by customer account, so all of one company's data sits together. Sharding by an incrementing id can create a hot shard that takes every new write. A poor key is difficult to change later.
What gets harder
- Queries and transactions that span shards need extra code or are unavailable.
- Rebalancing data when you add a shard is delicate work.
- Reporting often needs a separate warehouse that combines everything.
Try these first
Add indexes, tune the slow queries, move reads to replicas, cache hot results and upgrade the server. A single well-tuned PostgreSQL machine handles far more than most businesses will ever generate. Sharding fits genuinely huge datasets or write rates, and some systems such as MongoDB, Cassandra and Vitess include it as a built-in feature.
Questions, answered
Partitioning splits a table inside one server; sharding spreads the pieces over several servers.
Almost never. Other fixes come first.