Courseiva
Sharding →hardMultiple Choice

C100DBA Sharding Practice Question

A MongoDB sharded cluster has a collection with a hashed shard key on the field 'userId'. A query is executed that includes an equality condition on userId. How does mongos route this query?

⚠ Common exam trap

The trap here is believing that hashed shard keys prevent all targeted queries, when in fact equality queries on the hashed field are efficiently targeted.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

It computes the hash of the userId value and routes the query to the single shard that owns the chunk containing that hash value.

For equality queries on a hashed shard key field, mongos computes the hash of the value and uses its cached chunk metadata to route the query directly to the shard owning that hash range. This enables efficient targeted queries. Scatter-gather only occurs when the query lacks an equality condition on the hashed field.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    It computes the hash of the userId value and routes the query to the single shard that owns the chunk containing that hash value.

    Why this is correct

    With a hashed shard key, MongoDB computes a hash of the field value and uses that hash to determine chunk placement. For an equality query on the hashed field, mongos computes the same hash and can target the exact shard that owns the corresponding chunk. This makes equality queries on the hashed field efficient and targeted to a single shard.

  • ✗

    It broadcasts the query to all shards because hashed shard keys do not support targeted queries.

    Why it's wrong here

    Hashed shard keys do support targeted queries for equality conditions on the hashed field. mongos can compute the hash and route to the correct shard. Broadcasting only occurs when the query does not include an equality condition on the hashed field, such as range queries or queries on other fields. So this statement is incorrect.

  • ✗

    It routes the query to the primary shard of the cluster because hashed keys always map to the primary shard for reads.

    Why it's wrong here

    There is no concept of a primary shard for read routing in a sharded cluster. The primary shard is where unsharded collections reside, but sharded collections are distributed across all shards. Hashed keys do not route all reads to the primary shard; they route based on the hash value to the appropriate shard.

  • ✗

    It uses the shard key index to identify the shard but must contact the config servers to resolve the chunk location before routing.

    Why it's wrong here

    mongos caches the cluster metadata, including chunk locations, from the config servers. It does not contact the config servers for every query. For a targeted query, mongos uses its cached routing table to determine the shard. Contacting config servers on every query would introduce unacceptable latency and is not how MongoDB operates.

About these practice questions

Courseiva writes every C100DBA question from scratch — 222 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official MongoDB exam blueprint

This C100DBA practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DBA exam.