nerdexam
MongoDB

C100DBA · Question #132

Which of the following statements are true about the $match pipeline operator? Check all that apply.

All three statements (A, B, and C) are correct about the $match pipeline operator. A is correct because placing $match early in the pipeline filters out documents before they pass to later, more expensive stages - and if $match is the first stage, MongoDB can leverage existing…

MongoDB Fundamentals

Question

Which of the following statements are true about the $match pipeline operator? Check all that apply.

Options

  • AYou should use it early as possible in the pipeline
  • BIt can be used as many time as needed.
  • CIt has a sintax similar to findQ commands.

Explanation

All three statements (A, B, and C) are correct about the $match pipeline operator.

A is correct because placing $match early in the pipeline filters out documents before they pass to later, more expensive stages - and if $match is the first stage, MongoDB can leverage existing indexes, dramatically improving performance on large collections.

B is correct because $match can appear multiple times throughout a pipeline. This is useful when you want to filter broadly early on, perform transformations (e.g., $group, $project), and then filter again on the new computed fields.

C is correct (despite the "sintax" typo) because $match uses the exact same query syntax as find() - meaning standard query operators like $gt, $in, $and, $or, $regex, etc., all work identically inside $match.

Memory tip: Think of $match as a portable find() - it works the same way, can be placed anywhere, but always goes first when possible to keep your pipeline lean and fast. The mantra is: "Filter early, filter often."

Topics

#$match#aggregation pipeline#pipeline optimization#query syntax

Community Discussion

No community discussion yet for this question.

Full C100DBA Practice