Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

MongoDB Index Limits

MongoDB Index Limits


Additional overhead

Each index occupies a certain amount of storage space, and index operations are also required when performing insert, update, and delete operations. Therefore, if you rarely read from a collection, it is recommended not to use indexes.


Memory (RAM) usage

Since indexes are 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 lead to performance degradation.


Query restrictions

Indexes cannot be used by the following queries:

Therefore, it is a good habit to check whether your statements use indexes; you can use explain to view.


Index key restrictions

Starting from version 2.6, if the value of an existing index field exceeds the index key limit, MongoDB will not create an index.


Inserting documents exceeding the index key limit

If a document's index field value exceeds the index key limit, MongoDB will not convert any document into an indexed collection. Similar to the mongorestore and mongoimport tools.


Maximum limits