Pick the fix
A multi-tenant SaaS shards by order_id hash. Every tenant dashboard query now hits all 16 shards. Better shard key?
Hint 1 of 1
Which id does nearly every query include?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A tenant_id, with large tenants moved via a directory
Correct. Tenant queries stay on one shard; the directory handles the few giants.
The shard key should match how queries filter. Almost every query here is per tenant, so sharding by tenant_id keeps each on one shard; a directory moves the few huge tenants.
Why not the others?
- B
created_atrange. Every new order lands on the newest shard. - C Random shard per row. Every query becomes scatter-gather.
- D Keep
order_id, add more shards. More shards make fan-out worse.