[SERVER-27494] Avoid unwind on multi-key index field for covered index aggregation Created: 22/Dec/16 Updated: 08/Feb/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 3.4.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | 아나 하리 | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||
| Description |
|
I think unwind stage can be avoid when aggregation query only need index field (multi-key index field). And Also aggregation grouping or sorting stage can be solved via sorted index without quick sort processing. (I assume multi-key index has same structure with normal b-tree index.) We have below collections which has array field and multi-key index on that field.
And we want to aggregate apps and count for each app.
This aggregation query can't use multi-key index and need to expand (unwind) apps field of all documents and sort. |
| Comments |
| Comment by David Storch [ 12/Apr/22 ] | ||
|
It looks that got closed only because of some bookkeeping around project planning. Re-opening and sending back to the triage queue. | ||
| Comment by Taylor Graham [ 03/Nov/19 ] | ||
|
For those of us that rely on a multikey index for counts, this would be a massive win. | ||
| Comment by Asya Kamsky [ 08/Jun/18 ] | ||
|
This could also cover a count with $elemMatch, essentially something equivalent to:
is the same as
when a is an array 100% of the time, but it could use a multikey index in a covered fashion since unwind won't treat non-array any differently than array. Derived from related ticket | ||
| Comment by Kelsey Schubert [ 22/Dec/16 ] | ||
|
Hi matt.lee, Thank you for the improvement request. I'm sending this ticket to the Query Team for consideration. Kind regards, |