[DOCS-12475] Missing aggregation stages Created: 14/Feb/19  Updated: 30/Oct/23  Resolved: 16/Aug/21

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: Yulia Genkina (Inactive) Assignee: Naomi Pentrel (Inactive)
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 2 years, 23 weeks, 6 days ago
Epic Link: DOCSP-1769
Story Points: 0.1

 Description   

Description

Hi!

This page https://docs.mongodb.com/manual/reference/operator/aggregation/sort/#sort-operator-and-performance has a list of operators that should be used before using `$sort` at the bottom section of the page, namely `$project`, `$unwind`, and `$group`

asya pointed out that this list is incomplete, when she took a look at our in-person training, which is largely based on the documentation.

Making this ticket to bring attention to this. Is there a definitive list that should be put on the documentation page? I would love to know, so that I can also update the in-person training accordingly.

Thank you!

Scope of changes

  • Investigate performance relationships between $sort and other aggregation stages in context of index usage
  • Document any missing operators
  • $sort can only use indexes if it is the first pipeline stage or if after all $match stages.


 Comments   
Comment by Asya Kamsky [ 26/Aug/21 ]

yep, fixed.

 

Comment by Naomi Pentrel (Inactive) [ 16/Aug/21 ]

I believe this is now fixed - if anyone disagrees please reopen this ticket.

Comment by Naomi Pentrel (Inactive) [ 30/Jul/21 ]

asya can you confirm this is solved now with our previous changes to https://docs.mongodb.com/manual/reference/operator/aggregation/sort/#-sort-operator-and-performance ? 

Comment by Charlie Swanson [ 15/Feb/19 ]

ravind.kumar that's correct.

Comment by Ravind Kumar (Inactive) [ 15/Feb/19 ]

charlie.swanson - just to confirm, no other stages could occur between $match and $sort , but you can have multiple $match stages as long as they are all before $sort? e.g. you could have n $match stages followed by $sort, but if there is an interleaving stage of any other type, $sort cannot use an index.

Comment by Asya Kamsky [ 14/Feb/19 ]

charlie.swanson sounds about right.

Comment by Charlie Swanson [ 14/Feb/19 ]

I think that list is just $match? asya do you know of any others? After doing a brief code exploration it looks like it must be first or after all $matches.

Comment by Ravind Kumar (Inactive) [ 14/Feb/19 ]

It'd be easier to enumerate stages that can come before $sort for sort to still use an index... 

If that list of stages exist, I'd be happy to add it to the document cc charlie.swanson@mongodb.com for input.

 

Comment by Asya Kamsky [ 14/Feb/19 ]

I don't think you should be enumerating stages here.

It's likely always going to be incomplete then. It'd be easier to enumerate stages that can come before $sort for sort to still use an index...

Comment by Ravind Kumar (Inactive) [ 14/Feb/19 ]

We're very dependent on server providing guidance for performance related behavior as mentioned. If asya or someone else on the server team can provide us resources for making that list more complete, we can update the documentation from there. Worth mentioning that we would probably need to consider behavior specific to certain versions of MongoDB.

Generated at Thu Feb 08 08:05:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.