[SERVER-27150] Performance degradation with $sort on indexed field Created: 22/Nov/16 Updated: 06/Dec/22 Resolved: 22/Nov/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 3.3.12, 3.4.0-rc3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Vyacheslav Stroy | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10, Ubuntu Linux |
||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Assigned Teams: |
Query
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: |
Query plan of slow query:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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:
|
| Comments |
| Comment by Charlie Swanson [ 22/Nov/16 ] |
|
Hi kreig, It looks like you've run into Thanks |
| Comment by Ramon Fernandez Marina [ 22/Nov/16 ] |
|
Thanks for the detailed reproducer kreig. I'm able to observe the behavior your describe in 3.4.0-rc3, but not in 3.4.0-rc4 – would it be possible for you to upgrade and confirm whether you're still experiencing this issue? EDIT: never mind, that was pilot error on my part. I can confirm the same behavior is present on 3.4.0-rc4. Thanks, |