The ts
field has highest cardinality for me. That used along with field1
narrows down number of docs to about 1450.
I have such multiple queries, each with different field in place of field2
. So I cannot add compound index for all of them.
I am fine with the extra time it might need not being in index.
What I mainly want to know is, where should I add the {$match:{field2:{$gt:0}}}
?
Will merging it with first stage cause the entire document to be read for the filtering process or will mongodb just read that single field?
If it reads the entire document from disk for filtering, then I feel it would be better to put the {$match:{field2:{$gt:0}}}
after $project
stage.