Sample questions
Question 1Easy
Vertical partitioning means:
- Replicating the table to a second region for disaster recovery
- Splitting rows across servers
- Splitting a table's columns into separate tables or stores
- Adding RAM to the database
Answer: C. Splitting a table's columns into separate tables or stores
Explanation
For example, keeping large rarely-used columns like a profile bio apart from hot columns.
Step-by-step solution
- Vertical partitioning splits a table by columns, not rows.
- Columns that are rarely used or large can move to a separate table or store.
- Hot columns stay together for fast access.
- So vertical partitioning splits a table's columns into separate tables or stores (option C).
Why the other options are wrong
- A. Replicating to another region is disaster recovery, not partitioning.
- B. Splitting rows across servers is horizontal partitioning or sharding.
- D. Adding RAM is a hardware change, not a partitioning method.
Tip: Vertical partitioning = split by columns; horizontal partitioning = split by rows.
Question 2Easy
Sharding vs partitioning: which is the usual distinction?
- Sharding usually means partitions on different machines
- Partitioning always means vertical splitting of columns
- Sharding is only done in NoSQL databases, never in relational databases like MySQL
- They mean opposite things
Answer: A. Sharding usually means partitions on different machines
Explanation
Partitioning splits a table; sharding is the case where partitions live on separate servers.
Step-by-step solution
- Partitioning splits a table into parts.
- Sharding is the case where those parts live on separate servers.
- So a shard is a partition on a separate machine.
- So sharding usually means partitions on different machines (option A).
Why the other options are wrong
- B. Partitioning can split rows or columns, so it is not always vertical.
- C. Sharding is also done in relational databases such as MySQL.
- D. They are related: sharding is one form of partitioning, so they do not mean opposite things.
Tip: Partitioning splits a table; sharding puts the parts on separate machines.
Question 3Easy
- Rebuilding replicas from backups
- Running the same query on every shard in parallel and merging the results
- Recreating all indexes on one shard
- Moving data to a new shard layout as data or load grows
Answer: D. Moving data to a new shard layout as data or load grows
Explanation
Resharding redistributes data when shards fill up or become imbalanced; it is costly, so shard keys should be chosen carefully.
Step-by-step solution
- Resharding happens when shards fill up or become unbalanced.
- Data is moved to a new shard layout as the data or load grows.
- This is costly, so shard keys should be chosen with care.
- So resharding is moving data to a new shard layout (option D).
Why the other options are wrong
- A. Rebuilding replicas from backups is a recovery task, not resharding.
- B. Running a query on every shard and merging is scatter-gather.
- C. Recreating indexes on one shard is maintenance, not resharding.
Tip: Resharding is costly, so choose the shard key well at the start.
Question 4Easy
Which statement best describes sharding a very large users table?
- Compressing tables to save space
- Caching query results in memory
- Splitting data across nodes so each holds a subset
- Copying the full dataset to every node so any node can answer any query
Answer: C. Splitting data across nodes so each holds a subset
Explanation
Sharding (horizontal partitioning) spreads rows across machines so storage and write load scale out.
Step-by-step solution
- Sharding splits a very large table across machines.
- Each node holds a subset of the rows.
- So storage and write load can scale out.
- So sharding splits data across nodes so each holds a subset (option C).
Why the other options are wrong
- A. Compression saves space but does not spread rows across machines.
- B. Caching query results is a different technique.
- D. Copying the full dataset to every node is replication, not sharding.
Tip: Sharding spreads rows across machines so storage and writes scale out.
Question 5Medium
A social app shards by user_id. A celebrity's posts receive enormous traffic on one shard. What is this problem called?
- A hot partition (hot key)
- A cold start
- Phantom read caused by the repeatable-read isolation level
- Write skew
Answer: A. A hot partition (hot key)
Explanation
Skewed access concentrates load on one shard; fixes include caching, splitting the key or adding salt.
Step-by-step solution
- Sharding by user_id puts one user's posts on one shard.
- A celebrity's traffic all lands on that single shard.
- One overloaded key or partition is a hot partition.
- So the problem is a hot partition, also called a hot key (option A).
Why the other options are wrong
- B. A cold start is a term for a system with no warm cache or state, not this case.
- C. A phantom read is an isolation anomaly, not a traffic hotspot.
- D. Write skew is a concurrency anomaly, not a traffic hotspot.
Tip: A hot key sends too much traffic to one shard; fix with caching, salting or splitting the key.
Question 6Medium
What makes a good shard key?
- The row's creation timestamp alone, because time always increases evenly
- High cardinality, even spread, and alignment with common queries
- A column that changes on every update
- A boolean column such as is_active
Answer: B. High cardinality, even spread, and alignment with common queries
Explanation
Low-cardinality or monotonically increasing keys create hot shards; queries should usually hit one shard.
Step-by-step solution
- A good shard key has many distinct values, which is high cardinality.
- It spreads rows evenly across shards.
- It matches the common queries so each query hits one shard.
- So option B describes a good shard key (option B).
Why the other options are wrong
- A. A timestamp alone rises steadily, so new writes hit one shard and create a hotspot.
- C. A column that changes on every update makes rows move or cause churn and is not a stable key.
- D. A boolean has only two values, so it cannot spread data across many shards.
Tip: Pick a shard key with many values, even spread and match to the main query.
Question 7Medium
Consistent hashing with replication typically stores a key on:
- Only its owner node
- All nodes in the cluster so that any one of them can answer a read without forwarding
- Its owner node plus the next few distinct nodes clockwise
- A random node chosen per write
Answer: C. Its owner node plus the next few distinct nodes clockwise
Explanation
Walking clockwise to the next R distinct physical nodes gives replicas that are easy to locate.
Step-by-step solution
- Replicated consistent hashing stores each key on its owner node.
- It also copies the key to the next few distinct nodes clockwise.
- Walking clockwise makes the replicas easy to find.
- So the key is stored on its owner plus the next few distinct nodes clockwise (option C).
Why the other options are wrong
- A. Storing only on the owner is no replication.
- B. Storing on all nodes is full replication, not consistent-hash replication.
- D. A random node per write would make replicas hard to locate.
Tip: Consistent-hash replication: owner node plus the next distinct nodes clockwise.
Question 8Medium
In a Snowflake-style ID, 12 bits are a per-millisecond sequence. How many IDs can one machine generate per millisecond?
- 4,096
- 4,095,000
- 1,024
- 12
Answer: A. 4,096
Explanation
2^12 = 4,096
sequence values per millisecond per worker.
Step-by-step solution
- A 12-bit sequence has 2^12 possible values.
- 2^12 = 4,096.
- So one worker can issue 4,096 IDs per millisecond.
- So the answer is 4,096 (option A).
Why the other options are wrong
- B. 4,095,000 has no link to 12 bits; the sequence holds 4,096 values per millisecond.
- C. 1,024 is 2^10, not 2^12.
- D. 12 is the bit count, not the number of IDs.
Tip: N bits hold 2^n values; 12 bits give 4,096.
Question 9Hard
Why do consistent-hashing systems use virtual nodes (vnodes)?
- To let one key live on several unrelated rings
- To make the ring order keys alphabetically so range scans become cheap
- To spread each server across many ring points for balance
- To remove the need for replication
Answer: C. To spread each server across many ring points for balance
Explanation
With few physical nodes, ring arcs are uneven; many virtual points per server smooth the load and spread a failed node's data over many peers.
Step-by-step solution
- With few physical nodes, the ring arcs can be uneven.
- Each server gets many virtual points on the ring.
- That evens the load and spreads a failed node's data over many peers.
- So vnodes spread each server across many ring points (option C).
Why the other options are wrong
- A. A key lives on one ring position owner set, not on unrelated rings.
- B. Vnodes do not sort keys alphabetically; hashing scatters them.
- D. Vnodes do not remove the need for replication.
Tip: Virtual nodes smooth the load on a consistent-hash ring.
Question 10Hard
A Snowflake-style 64-bit ID uses 41 bits for milliseconds since a custom epoch. About how long until it overflows?
- About 24 days
- About 136 years
- About 41 years
- About 69 years
Answer: D. About 69 years
Explanation
2^41 ms ≈ 2.2 × 10^12 ms
≈ 69.7 years.
Step-by-step solution
- 41 bits count milliseconds, so the maximum is 2^41 ms.
- 2^41 ms is about 2.2 × 10^12 ms, which is about 2.2 × 10^9 seconds.
- Divided by about 31.56 million seconds a year, that is about 69.7 years.
- So it overflows in about 69 years (option D).
Why the other options are wrong
- A. 24 days would need only about 31 bits of milliseconds, not 41.
- B. 136 years does not match 2^41 ms; the answer is about 69.
- C. 41 is the bit count, not the number of years.
Tip: Years = 2^bits ms ÷ 1000 ÷ 31,557,600 seconds a year.
Practise all 20 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →