In this recipe, we will be looking at how to capture queries that have longer execution times. By identifying slow running queries, you can work towards implementing appropriate database indexes or even consider optimizing the application code.
Assuming that you are already running a MongoDB server, we will be importing a dataset of around 100,000 records that are available in the form of a CSV file called chapter_2_mock_data.csv
. You can download this file from the Packt website.
- Import the sample data into the MongoDB server:
mongoimport --headerline --ignoreBlanks --type=csv -d mydb -c mockdata -h localhost chapter_2_mock_data.csv
This will give us the following result:
2017-06-23T08:12:02.122+0530 connected to: localhost 2017-06-23T08:12:03.144+0530 imported 100000 documents
- Connect to the MongoDB instance and open a MongoDB shell:
mongo localhost
- Check that the documents are in the right place:
> use mydb switched to...