The shard key determines which shard stores each row. Choose carefully.
Good shard keys:
- High cardinality (many unique values)
- Even distribution (no hotspots)
- Used in most queries (avoid cross-shard)
Examples:
user_id: Good for user-centric apps. Each user's data on one shard.order_id: Good for order lookups. Random distribution.
Bad shard keys:
country: Low cardinality, uneven distributioncreated_at: Sequential, all new writes hit one shard
You cannot easily change the shard key later. Invest time choosing it correctly.