A
database index is a data structure that improves the speed of data retrieval
operations on a database collection at the cost of additional writes and
storage space to maintain the index data structure.
Adding
appropriate indexes on large collections will typically have the greatest
impact on the performance of a database, so that only a small percentage of
queries need to scan the entire collection. Without indexes, mongoDB must scan
every document in the collection that match query statement. MongoDB defines
indexes at the collection level and supports indexes on any field or sub-field
of the documents in a MongoDB collection.
In
ideal situations, you no need to index all the fields in the collection, choose
what fields makes your frequent queries for indexing.
No comments:
Post a Comment