Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
3.3.12, 3.4.0-rc3
-
None
-
Windows 10, Ubuntu Linux
-
Query
-
ALL
-
Description
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).
Attachments
Issue Links
- duplicates
-
SERVER-7568 Aggregation framework favors non-blocking sorts
-
- Closed
-