Databases · Senior · Question 23 of 75
What makes a good shard key?
- 1A timestamp, so new data goes to one shard
- 2A boolean column
- ✓Correct answer: High cardinality, even distribution of data and load, and alignment with the most common queries (e.g. tenant ID)
Explanation
A time-based key sends all new writes to one shard (a hotspot). Queries that cross shards are expensive, so keep a tenant's data together.