MongoDB explain winning plan shows “EOF”
-
04-01-2021 - |
سؤال
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.
المحلول
Ok, I found out why. Apparently I was querying against the admin database. Always run use <db>
guys
نصائح أخرى
In my case, on my query I put an incorrect collection name. Always check that too.