All Questions
Sharding medium

In an E-Commerce platform, why might you choose to shard the `Orders` table by `user_id` rather than the more obvious `order_id`?

  1. A Because it is significantly easier for the database to index strings like 'UserIDs' than random sequence integers.
  2. B To achieve 'Colocation', ensuring that all of a specific user's orders reside on the same physical shard as their main user profile for high-performance retrieval.
  3. C To prevent the 'Order ID' sequence from running out of available unique numbers across multiple servers.
  4. D Because `order_id` is typically protected by data privacy laws that prevent it from being used in routing algorithms.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions