Jul 22, 2015

Indexing Limitations in MongoDB

This limitation regards to MongoDB version 2.6 and above.

1- As we know,  that  the indexes are stored in RAM, we should make sure that the index size does not exceed the RAM limit. If index size increases  than RAM will start deleting some indexes and hence causing performance loss.

2- Total size of an index entry must be less than 1024 bytes but remember it can include overhead depending on the BSON type.

3- If index entry of existing document exceed to index key limit, MongoDB will deny to create an index on a collection. In previous version mongoDB would not deny to create but will not index the document.

4- Re-indexing operation will give error if index entry field exceeds the index key limit.

5- Update to indexed field will give error if entry would exceed the index key limit.

6- A collection can't have more than 64 index.

7- The name length can't be more than 128 character.

8- A compound index can have maximum 31 fields indexed.


9- If you want to create 2dsphere index on a field than field must hold geometry data in the form of coordinate pairs or GeoJSON data. If you try to insert a document with non-geometry data in a 2dsphere indexed field, or build a 2dsphere index on a collection where the indexed field has non-geometry data, the operation will fail.