[DOCS-15990] Unclear when an aggregation pipeline can use indexes Created: 27/Mar/23  Updated: 06/Nov/23  Resolved: 02/Nov/23

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

Type: Task Priority: Minor - P4
Reporter: Maxime Beugnet Assignee: Lauren Tran
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 13 weeks, 6 days ago
Story Points: 2

 Description   

https://www.mongodb.com/docs/manual/core/aggregation-pipeline-optimization/#indexes

In this section, I was expecting to find the list of stages that completely prevent the use of indexes further down the pipeline. 

For example I was convinced that $project and $unset were preventing any indexes from being used based on the documentation but I was surprised to see that these 2 pipelines can actually both use an index on {name:1}.

db.c.explain(true).aggregate([{"$project": {"age":0}},{"$match": {name:"Max"}}])
db.c.explain(true).aggregate([{"$unset": "age"},{"$match": {name:"Max"}}])

 

Can we improve the doc to be more precise?
Thanks!



 Comments   
Comment by Ashley Brown [ 02/Nov/23 ]

Closing this ticket. There doesn't appear to be consensus between engineering and technical services about how to move forward with any changes. When consensus is reached, feel free to reopen the ticket with the consensus changes in the description. If you have questions, please reach out to Sarah Olson or me directly. Thanks! 

cc: sarah.olson@mongodb.com 

Comment by Asya Kamsky [ 19/Oct/23 ]

maxime.beugnet@mongodb.com  FYU, this page seems to answer your question... 

Comment by Lauren Tran [ 19/Oct/23 ]

Closing this ticket as discussed with the OP and members of the ts-experts-queries channel as the list of stages approach is not aligned with the behavior ndexes and aggregation. 

Comment by Maxime Beugnet [ 28/Mar/23 ]

I thought I did, based on the documentation. But I noticed this gap so...

Now I'm John Snow... I know nothing...

Comment by Jeffrey Allen [ 27/Mar/23 ]

Hi maxime.beugnet@mongodb.com, I agree that this would be useful information to add to the docs. Do you happen to know which stages prevent index usage?

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