Reputation: 29
Hi how can check what index use , and number of scanned objects in aggregate query , something similar to db.collection.find().explain() ?
Upvotes: 0
Views: 378
Reputation: 36784
Right now, there is no explain functionality for aggregate()
yet. However, in general indexes are only used for certain operators if they are the first element in the aggregation operator pipeline. For example, $match
and $geoNear
.
So in order to figure out which index is being used, simply run the explain()
on a find()
where the query matches your first $match
options.
explain()
functionality for aggregate()
is an issue in JIRA: https://jira.mongodb.org/browse/SERVER-4504 — I would suggest you vote for the issue on JIRA as well.
Upvotes: 1