Sharding medium
In database architecture, why is a low-cardinality boolean column (like `is_active`) considered an extremely poor choice for a Shard Key?
- A The data type is too small for modern hash functions to process effectively.
- B It practically limits the entire cluster to just two servers (True/False), making it impossible to scale the system further.
- C Most distributed databases do not allow the use of boolean values as a partition key.
- D It would require too many secondary index lookups to find any specific record.
Answer: B. It practically limits the entire cluster to just two servers (True/False), making it impossible to scale the system further.
A Shard Key's 'Cardinality' is the number of unique possible values. To scale to a 1,000-node cluster, your shard key must have at least 1,000 (and ideally millions) of unique values. If you use a Boolean or a 'Gender' column, you are hitting a 'Scalability Wall'—even if you have 100 servers, 98 of them will remain empty because there are only two possible places for the data to land. The best shard keys are those with extremely high cardinality, such as User IDs or unique timestamps, which allow for granular splitting and infinite growth.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In an E-Commerce platform, why might you choose to shard the `Orders` table by `user_id` rather than the more obvious `order_id`?
- In the context of database scaling, what is the fundamental difference between 'Vertical Partitioning' and 'Horizontal Partitioning' (Sharding)?
- If Shard A fails in a large cluster, and its incoming traffic is automatically re-routed to Shard B, what is the risk of a 'Cascading Failure'?
- In a standard 'Modulo Sharding' setup (`key % N`), what is the primary consequence of adding a new server to the cluster (increasing N from 10 to 11)?
- From an engineering perspective, when should you choose 'Vertical Scaling' (a bigger server) over 'Horizontal Scaling' (Sharding)?
- Which sharding strategy is mathematically optimized for efficient 'Range Scans' (e.g., retrieving all records created between January and March)?