Introduction
In the previous chapters, we learned about the MongoDB query language and various query operators. We learned how to write queries to retrieve data. We also learned about various commands used to add and delete data and also to update or modify a piece of data. We ensured that the queries bring us the desired output; however, we did not pay much attention to their execution time and their efficiency. In this chapter, we will focus on how to analyze a query's performance and optimize its performance further, if needed.
Real-world applications are made up of multiple components, such as a user interface, processing components, databases, and more. The responsiveness of an application is dependent on the efficiency of each of these components. The database component performs different operations, such as saving, reading, and updating data. The amount of data a database table or collection stores, or the amount of data being pushed into or retrieved from a database...