YouTip LogoYouTip

Mongodb Indexing Limitations

# MongoDB Indexing Limitations * * * ## Extra Overhead Each index takes up a certain amount of storage space and requires operations on the index during insert, update, and delete operations. Therefore, if you rarely perform read operations on 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 index size exceeds the memory limit, MongoDB will delete some indexes, which will lead to performance degradation. * * * ## Query Limitations Indexes cannot be used in 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, which can be viewed using explain. * * * ## Index Key Limitations 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 Index Key Limit If the value of an indexed field in a document exceeds the index key limit, MongoDB will not convert any documents into an indexed collection. This is similar to the mongorestore and mongoimport tools. * * * ## Maximum Limits * A collection cannot have more than 64 indexes * The length of an index name cannot exceed 128 characters * A compound index can have at most 31 fields
← Mongodb ObjectidMongodb Advanced Indexing β†’