1. Additional Costs:
Each index occupies a certain amount of storage space, and the indexes need to be manipulated when inserting, updating, and deleting operations. Therefore, if you seldom read the collection, we recommend that you do not use the index.
2. Memory Usage:
Because the index is stored in memory (RAM) , you should ensure that the size of the index does not exceed the memory limit. If the size of the index is greater than the memory limit,MongoDB will delete some indexes, which will result in degraded performance.
3. Query Restrictions:
The index cannot be used by the following query:
Regular expressions and non-operators, such as $nin, $not, and so on.
Arithmetic operators, such as $mod, and so on.
$where clauses
Therefore, it is a good habit to detect whether your statements use indexes, which can be viewed with explain .
4. Index Key Restrictions:
Starting with the 2.6 version, if the value of an existing indexed field exceeds the index key limit, The index is not created in MongoDB.
5. Insert document over index key limit:
If the index field value of the document exceeds the limit of the index key,MongoDB does not convert any documents into indexed collections.
6. Maximum Range
The index in a collection cannot exceed
Index name cannot be longer than a maximum of eight characters
A composite index can have up to a maximum of one field
MongoDB Index Limit