C100DEV Aggregation Framework Practice Question
Which aggregation operator is most appropriate for counting the total number of documents in a collection?
⚠ Common exam trap
Candidates often overcomplicate the task by writing a full $group stage with a $sum accumulator, missing the fact that $count provides a more concise and readable built-in alternative.
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
✓
$count
The $count stage is a specialized aggregation stage that returns a document containing the number of input documents at that point in the pipeline. It is shorthand for a $group stage with a $sum accumulator. Using $count is more readable and concise than building a manual $group stage, making it the best practice for simple document counting tasks within an aggregation pipeline.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
$group with $sum
Why it's wrong here
While this method works, it is more verbose than necessary. The $count stage provides a cleaner, more readable syntax for the exact same result. In professional MongoDB development, using the specialized $count stage is preferred for its simplicity and clear intent within the aggregation pipeline structure.
- ✓
$count
Why this is correct
$count is the designated stage for returning a count of documents. It simplifies the pipeline by replacing the need for a $group operation, making it the most efficient and readable choice for counting records after applying any necessary filters in the preceding stages of your aggregation.
- ✗
$limit
Why it's wrong here
$limit is used to restrict the number of documents passed to the next stage, not to count them. It doesn't provide the total number of items, as it stops once the threshold is reached. Therefore, it is entirely inappropriate for calculating a total count of collection records.
- ✗
$match
Why it's wrong here
$match is a filtering operator. It determines which documents are passed forward but does not perform any counting logic. Using it alone will return the documents themselves, not a numeric count, so it cannot fulfill the requirement of returning the total count of documents in the collection.
About these practice questions
One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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 C100DEV 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 C100DEV exam.