3

I've been working on optimizing my queries on some 2 million documents in MongoDB and I tried to use explain on aggregate functions, but it would display

"winningPlan" : {
      "stage" : "EOF"
    },

Prior to this, the function would show the winning plan with the stages such as "Fetch", but after I tried a few different syntax in writing the aggregate command now it is showing "EOF". I tried to simplify my command to a find().explain() function but it is still the same. Anyone has any ideas?

On a second note, has anyone figured out how to explain("executionStats") on an aggregate query. I see that the function has been implemented here, but when I run it I get "EOF" as well as a basic explain() results. Is it because my MongoDB is not updated to 3.5.5? Is this functionality supported for versions below 3.5.5? Many thanks in advance.

Lumo Woong
  • 163
  • 2
  • 11

2 Answers2

7

Ok, I found out why. Apparently I was querying against the admin database. Always run use <db> guys

Lumo Woong
  • 163
  • 2
  • 11
1

In my case, on my query I put an incorrect collection name. Always check that too.

Michael Green
  • 25,255
  • 13
  • 54
  • 100
Jaziel_Inc
  • 29
  • 3