This is the pipline I’m trying to run:
[{
$match: {
$and: [
{
epoch: {
$gt: start,
$lt: end
}
}, {
site: "my site"
}
]
}
},{"$group" : {_id:"$file", count:{$sum:1}}}]
The above is slower than:
{"$group" : {_id:"$file", count:{$sum:1}}}
The $match operator slows it down. To note: epoch, file, and site are all indexed descending. Maybe I am misunderstanding something, but intuitively, an indexed match before a group by operation should be faster than a singular group by.
Is this just a performance issue? Speed doesn’t matter a whole lot in my particular application. I just want to learn what MongoDB is doing underneath the hood.