In plain words
Sharding splits your data across several databases by a shard key, such as account ID, so each holds only part of the rows and the writes are spread out, at the cost of harder queries across shards.
Where you see it
Harbor's deploy logs pass 3 billion rows, and one Postgres primary can't keep up with the writes even after indexing and a bigger machine. The team shards the table by account ID across 8 nodes with Citus, and every query for one account still goes to exactly one shard.
What goes wrong
- Sharding before you need to
Indexes, a read replica, partitioning or archiving old rows, and a bigger machine take a single Postgres a long way. Sharding makes every query, migration and backup more complex, so it belongs at the end of the list.
- A shard key that piles onto one shard
Sharding by date sends all of today's writes to one shard, and your largest customer can overload theirs. Pick a key that spreads the load and that most queries include.
- Queries that need every shard
A report across all accounts now asks every shard and combines the answers, and a transaction spanning two shards loses its usual guarantees. Choose the key around the queries you run most.
What to tell your agent
Quick check
Sign in to earn +10 XP for itHarbor shards its deploy logs by account ID. Which query becomes expensive?