Hi all,
I have created indexes in the format {a: 1, b: 1, c: 1, d:1, e:1} on collection which has 11.1 million documents.
And the base query which I am applying is like
{a: true, b: ‘text’, c: {"$in": [long array]}, d: {"$in": [‘A’, 'B]}}.sort(e: 1)
So the query is using this index which is mentioned above, but the query is still taking 13 sec, and its returning 72 K records.
If I reduce the values for the ‘c’ attribute to a smaller array eg: [1,2] then the results are returned quicker.
But as soon as the array size is grown the time taken s increasing.
So what should be done in this case?
What I observed is if there is no sorting then the query is running faster but if I apply sorting the time is increasing and ‘Sorted in Memory’ is marked as yes. What type of index I should create so that there is no in-memory sort?
Thanks for the help in Advance!