Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-15990

Unclear when an aggregation pipeline can use indexes

    • Type: Icon: Task Task
    • Resolution: Cannot Reproduce
    • Priority: Icon: Minor - P4 Minor - P4
    • Server_Docs_20231106
    • Affects Version/s: None
    • Component/s: manual, Server
    • Labels:
      None
    • 2

      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!

            Assignee:
            lauren.tran@mongodb.com Lauren Tran
            Reporter:
            maxime.beugnet@mongodb.com Maxime Beugnet
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              23 weeks, 6 days ago