From 61af64c72e8fa637590d15bc27e761cba29a9b7b Mon Sep 17 00:00:00 2001 From: Kshitij Date: Sun, 10 Nov 2024 12:16:58 +0530 Subject: [PATCH] Simplified query 6. --- Practical/Practical Exam/MongoDB/M4 - Aggregation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Practical/Practical Exam/MongoDB/M4 - Aggregation.md b/Practical/Practical Exam/MongoDB/M4 - Aggregation.md index b823900..2468da4 100644 --- a/Practical/Practical Exam/MongoDB/M4 - Aggregation.md +++ b/Practical/Practical Exam/MongoDB/M4 - Aggregation.md @@ -168,14 +168,14 @@ for (let i = 1; i <= 10000; i++) { db.Employee.insertOne({ Emp_id: i, Name: `Employee ${i}`, - Designation: `${Math.floor(Math.random() * 5) + 1}` + Designation: `Work ${i*5}` }); } -// Wait for it to insert 10000 documents +// Wait for it to insert 10000 documents! // Time without index let startTime = new Date(); -db.Employee.find({ Emp_id: 7500 }).toArray(); +db.Employee.find({ Emp_id: 7500 }) let endTime = new Date(); print("Time taken to search without index: " + (endTime - startTime) + " ms"); @@ -184,7 +184,7 @@ db.Employee.createIndex( { Emp_id: 1 }); // Time with index startTime = new Date(); -db.Employee.find({ Emp_id: 7500 }).toArray(); +db.Employee.find({ Emp_id: 7500 }) endTime = new Date(); print("Time taken to search with index: " + (endTime - startTime) + " ms");