Having a mongodb with around 100GB of data and per field in the $match expression, i have an index (single field index).
Now I tried aggregate() and wrote $project as first part in the pipeline, $match behind this.
The aggregation runs and returns correct results, but it takes for hours! Does this really process the filtered ($match) data only or does mongo aggregate on the full range of data and filter afterwards?
In my test case, $match filters around 150MB (instead of the full data size of 100GB).
By accident, I changed the order and wrote $match before $project in the pipeline definition. This way, it was done within few seconds.
When does mongodb reduce the input data usually and does it also deal with the index for fields in $match?