[SERVER-28312] take slice or element of array before materializing it Created: 14/Mar/17 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Asya Kamsky | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | optimization, performance | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Query Optimization
|
| Participants: |
| Description |
|
When a large array has format
and aggregation does something like
then as array "a" gets larger, materializing it into "$a.b" becomes more expensive - and just taking $slice (or $arrayElemAt) and then extracting "a.b" can be significantly faster. Discovered when working with very large arrays (over 10,000) and doing $slice and two $arrayElemAt operations in the same stage and having it perform 100x worse than explicitly taking slice first and then extracting b out of smaller result. |