9. Performance
Activity 9.01: Optimizing a Query
Solution:
Perform the following steps to complete the activity:
- Open your mongo shell and connect to the
sample_supplies
database on the Atlas cluster. First, you need to find how many records the query returns. The following snippet shows acount
query, which gives the number of backpacks sold at the Denver store:db.sales.count( { "items.name" : "backpack", "storeLocation" : "Denver" } )
- The query returns a count of
711
records. - Next, analyze the query given by the analytics team using the
explain()
function, and print the execution stats, as...