Query Analysis after Indexes
In the Query Analysis section, you analyzed the performance of a query that did not have suitable indexes to support its query condition. Because of this, the query scanned all 23539
documents in the collection to return 484
matching documents. Now that you have added an index on the year
field, let's see how the query execution stats have changed.
The following query prints the execution statistics for the same query:
db.movies.explain("executionStats").find( Â Â Â Â { Â Â Â Â Â Â Â Â "year" : 2015 Â Â Â Â }, Â Â Â Â { Â Â Â Â Â Â Â Â "title" : 1, Â Â Â Â Â Â Â Â "awards.wins" : 1 Â Â Â Â } ).sort( Â Â Â Â {"awards.wins" : -1} )
The output for this is slightly different than the previous one, as shown in the following...