0
0
MongoDBquery~5 mins

Choosing a good shard key in MongoDB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a shard key in MongoDB?
A shard key is a field or set of fields that determines how data is distributed across different shards in a MongoDB cluster.
Click to reveal answer
beginner
Why should a shard key have high cardinality?
High cardinality means many unique values, which helps distribute data evenly across shards and avoids hotspots.
Click to reveal answer
beginner
What happens if a shard key has low cardinality?
Data may cluster on a few shards causing uneven load and poor performance.
Click to reveal answer
intermediate
How does a shard key affect query performance?
A good shard key allows queries to target specific shards, reducing the amount of data scanned and improving speed.
Click to reveal answer
intermediate
What is a common mistake when choosing a shard key?
Choosing a shard key that is monotonically increasing, like a timestamp or ObjectId, can cause all writes to go to one shard, creating a bottleneck.
Click to reveal answer
Which property is important for a good shard key?
AHigh cardinality
BLow cardinality
CAlways the _id field
DA field with only a few distinct values
What is a risk of using a monotonically increasing shard key?
AShards automatically balance
BData is evenly spread
CQueries become faster
DAll writes go to one shard causing a hotspot
How does a good shard key improve query performance?
ABy targeting queries to specific shards
BBy duplicating data on all shards
CBy ignoring the shard key in queries
DBy making queries scan all shards
Which shard key choice can cause uneven data distribution?
AA field with many unique values
BA field with few unique values
CA hashed shard key
DA compound shard key
What is a compound shard key?
AA shard key that is always _id
BA shard key with only one field
CA shard key made of multiple fields
DA shard key that changes over time
Explain what makes a shard key good for MongoDB sharding.
Think about how data spreads and how queries use the shard key.
You got /4 concepts.
    Describe the problems caused by choosing a monotonically increasing shard key.
    Consider how data is inserted over time.
    You got /4 concepts.