InterviewSolution
| 1. |
Suppose we have the following indexes on the sample collection: |
|
Answer» Indexes are important to consider while designing the databases as they impact the performance of the APPLICATIONS. Without index, query will perform collection scan in which all the documents of the collection are scanned one by one to find the matching fields of the query. If we have indexed for a particular query, MongoDB can use the index to limit the number of documents scanned to execute the query as the indexes store the values of the query in ascending or descending ordered form. While the indexes help in improving the performance of find operations for write operations like insert and update there can be a SIGNIFICANT NEGATIVE impact of adding indexes as with modifications with each write MongoDB WOULD need to update the indexes associated with the index also. This would be overhead on the system and we may end up with performance degradation. So while the find() will improve performance the operators updateOne and insertOne would degrade the performance as with every update or insert related indexes would need to be updated. |
|