3.37.1. Extra expenses ¶
Each index occupies a certain amount of storage space, and it is also necessary to operate on the index during insert, update and delete operations. Therefore, if you rarely read the collection, it is recommended that you do not use the index.
3.37.2. Memory (RAM) usage ¶
Since the index is stored in RAM, you should make sure that the size of the index does not exceed the memory limit.
If the size of the index is larger than the memory limit, MongoDB will delete some indexes, which will cause performance degradation.
3.37.3. Query restriction ¶
The index cannot be used by the following query:
Regular expressions and non-operators, such as $nin, $not, etc.
Arithmetic operators, such as $mod, etc.
$where clause
Therefore, it is a good habit to check whether your statement uses an index, which can be checked with explain.
3.37.4. Index key limit ¶
从2.6版本开始,如果现有的索引字段的值超过索引键的限制,MongoDB中不会创建索引。
3.37.5. Insert document exceeds index key limit ¶
If the value of the index field of a document exceeds the limit of the index key, MongoDB does not convert any document into a collection of indexes. Similar to mongorestore and mongoimport tools.
3.37.6. Maximum range ¶
Cannot have more than 64 indexes in the collection
The length of the index name cannot exceed 128 characters
A composite index can have up to 31 fields