Home >>MongoDB Tutorial >MongoDB Indexing Limitations

MongoDB Indexing Limitations

Extra Overhead

Each index occupies some space and causes every insert, update and delete to have an overhead. But it makes sense to not use indexes if you rarely use your collection for learning operations.

RAM Usage

Since indexes are stored in RAM, you should ensure that the index's total size does not reach the RAM limit. If the total size increases the RAM size, some indexes will start deleting, causing loss of performance.

Query Limitations

In queries that use − do not use indexing

  • Regular expressions or operators of negation, such as $nin, $not, etc.
  • Operators of arithmetic such as $mod, etc.
  • Clause $where

Therefore, checking the index use for your queries is always advisable.

Index Key Limits

Starting with version 2.6, when the value of the current index field reaches the index key limit, MongoDB will not create an index.

Inserting Documents Exceeding Index Key Limit

When the indexed field value of this document reaches the index key limit, MongoDB will not insert any document into the indexed collection. With mongorestore and mongoimport utilities, the same is the case.

Maximum Ranges

  • There cannot be more than 64 indexes in a collection.
  • The length of the name of the index cannot exceed 125 characters.
  • There can be a maximum of 31 fields indexed in a compound index.

No Sidebar ads