-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.3.12, 3.4.0-rc3
-
Component/s: Aggregation Framework
-
None
-
Environment:Windows 10, Ubuntu Linux
-
Query
-
ALL
-
The $sort operator on indexed field slows down aggregation pipeline execution up to 200 times when used in conjunction with $match on another indexed field.
Performance degrades linearly on collection growth. It becomes a huge problem after 1 000 000 docs. Aggregations on my production environment with 9 000 000 docs collection take more than 4s.
It seems that problem itself is related to the non-optimal index usage.
I found only two options:
- Remove the index on the sorted field (unacceptable in my case).
- Add the compound index on both fields (not the best decision in case of multiple queries on various fields with different sort order).
- duplicates
-
SERVER-7568 Aggregation framework favors non-blocking sorts
- Closed