mongodb query needs FETCH stage despite all fields in $match being in the compound index
23:14 10 Apr 2026

Example 1:

https://mongoplayground.net/

There is a FETCH in the winningPlan. This is because of the:

      $or: [
        {
          f_a: 1
        },
        {
          f_b: 0
        }
      ]

Both f_a and f_b are part of the compound index. However, due to complexity of from the $or, it's not able to create the indexBounds for the these two fields. However, even though the indexBounds are not clean, given that these two fields are still part of the compound index, there is no need to FETCH the full document, but yet it does.

mongodb mongodb-query mongodb-indexes