C100DEV Aggregation Framework Practice Question
Exhibit
db.users.aggregate([
{ $project: { _id: 0, name: 1, age: 1 } },
{ $match: { age: { $gt: 25 } } }
])Refer to the exhibit. Why is this pipeline considered suboptimal?
⚠ Common exam trap
Test-takers frequently place $project before $match, failing to realize this prevents the database from efficiently utilizing indexes.
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
✓
The $match stage should come before $project.
The pipeline is suboptimal because it performs projection before filtering. By projecting fields first, the database processes every document in the collection. If the $match stage were moved to the beginning, the database could potentially use an index to filter documents before performing the field projection, reducing the amount of data the projection logic needs to handle, thus improving overall performance.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The $project stage is too slow.
Why it's wrong here
$project is generally efficient, but the issue here is the sequence, not the stage itself. Performing projections on the full collection before filtering is inherently wasteful because you are transforming data that you will ultimately discard in the subsequent $match stage, leading to unnecessary CPU usage.
- ✓
The $match stage should come before $project.
Why this is correct
Filtering with $match should occur early to reduce the document count. By placing $match first, you take advantage of indexing to reduce the working set. Projecting afterward ensures the transformation is only applied to the filtered subset, which is far more efficient than processing all documents first.
- ✗
The _id: 0 syntax is invalid.
Why it's wrong here
The syntax _id: 0 is perfectly valid in a $project stage to exclude the _id field from the result set. It is a standard practice when you only want to retrieve specific user data without including the auto-generated ObjectID, so this is not a cause for suboptimal performance.
- ✗
$match cannot follow $project.
Why it's wrong here
The aggregation pipeline allows any stage to follow any other stage as long as the output of the previous stage satisfies the input requirements of the next. You can absolutely put $match after $project, but doing so is inefficient for performance reasons, not because it is syntactically disallowed.
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.