MongoDB index limitations
Extra overhead
Each index occupies a certain storage space, and the index also needs to be operated during insert, update and delete operations. Therefore, if you rarely read from the collection, it is recommended not to use an index.
Memory (RAM) usage
Since 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 larger than the memory limit, MongoDB will delete some indexes, which will cause performance degradation.
Query restrictions
The index cannot be used by the following queries:
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. You can use explain to check.
Index key limit
Starting from version 2.6, if the value of the existing index field exceeds the index key limit, no index will be created in MongoDB.
Inserting documents beyond the index key limit
If the index field value of the document exceeds the index key limit, MongoDB will not convert any document into an indexed collection. Similar to the mongorestore and mongoimport tools.
Maximum range
The index in the collection cannot exceed 64
The length of the index name cannot exceed 125 Characters
A composite index can have up to 31 fields