![]() The next important value to look for in detail is docsExamined which is the number of documents scanned during the query execution stage. A 'work unit' might consist of examining a single index key, fetching a single document from the collection, applying a projection to a single document, or doing a piece of internal bookkeeping. The works variable tells us the number of work units performed by the query execution stage. In MongoDB query executions divide their work into small units. ' nReturned' is the total number of records returned by the database. In the details section, you’ll see a stage variable named COLLSCAN which tells us that the database searched every collection in the database to get results. Keep in mind I am not using any kind of index and it can be seen in the screenshot yellow triangle. Now if you take a closer look, you'll see it took 1128 ms by MongoDB to complete this query. This is a screenshot of MongoDB Compass, which will help us dig deep into the explain method and analyze it. This is a simple query and I believe if you’re reading this you must have a good idea of the 'find' query in MongoDB. Let's say I want to find all Ukrainian developers. I used mgodatagen to create dummy data and added 5 million records just to be as practical as I can be in terms of the number of records in a real-life production database. ![]() Let’s walk you through the database we’ll be using: 'developer' is the collection name and the document consists of first_name, last_name, email, date of birth (dob), age, language, country, and experience. The article covers the following chapters (click to navigate): Mgodatagen (CLI tool to generate fake records).Toolsīefore we start here are the main tools I’ll be using: We will be figuring out how MongoDB executes a query, the amount of time it takes, which index is being used and why. This article will focus on the performance of MongoDB (No-SQL), starting from basic queries to complex ones and explaining them along the way using MongoDB. However, with No-SQL there is only a handful resources, which is why we end up making poor choices either selecting or using No-SQL databases. There are a lot of articles on improving the performance of SQL databases, optimization, and their limitations. ![]() So of course we need databases to save the data and retrieve it when needed. Huge amounts of data are exchanged every day, and virtually everything has made its way on to the internet. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |