MongoDB Indexing Limitations - MongoDB

What are the limitations for indexing?

In this chapter, we will explain Indexing Limitations and its other components.

Extra Overhead

Every index will occupy some space as well as it will cause an overhead on every insert, update and delete. Therefore if you rarely use collection for read operations, then it is suggested not to use indexes.

RAM Usage

As indexes are stored in RAM, ensure that the total size of the index is not exceeding the RAM limit. If the total size increases the RAM size, then it will start deleting some indexes, which causes performance loss.

Query Limitations

Indexing cannot be used in queries which use

  • Regular expressions or negation operators like $nin, $not, etc.
  • Arithmetic operators like $mod, etc.
  • $where clause

Therefore, it is always suggested to verify the index usage for your queries.

Index Key Limits

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

Inserting Documents Exceeding Index Key Limit

MongoDB does not insert any document into an indexed collection if the indexed field value of the document exceeds the index key limit. Same is the case with mongorestore and mongoimport utilities.

Maximum Ranges

  • A collection cannot have more than 64 indexes.
  • Length of the index name cannot be longer than 125 characters.
  • Compound index can have maximum 31 fields indexed.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

MongoDB Topics