Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-2008

Change .explain().aggregate() to behave like .explain().find()

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Developer Tools

      After a conversation with Anna on Slack, we've found that .explain().aggregate() works different than .explain().find() and it should be fixed. However, this is inherited behaviour from the legacy mongo shell, so it would be a breaking change. The public documentation is also outdated, as the expected behaviour is what findd oes (which prints the explain plan) and not what aggregate does (which returns the explain plan): https://www.mongodb.com/docs/manual/reference/command/explain/#output


      This affects the IntelliJ plugin, and likely any tool that generates explain plans dynamically, as this inconsistency makes the code generation more complicated.

      The workaround is to default to use the options parameter that is available in all methods (usually the last parameter).

        1. image-2025-02-05-12-47-23-649.png
          88 kB
          Kevin Mas Ruiz
        2. image-2025-02-05-12-47-30-349.png
          18 kB
          Kevin Mas Ruiz

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.mas@mongodb.com Kevin Mas Ruiz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: