3.37. MongoDB index limit

发布时间 :2025-10-25 12:32:56 UTC      

3.37.1. Extra expenses

Each index occupies a certain amount of storage space, and it is also necessary to operate on the index during insert, update and delete operations. Therefore, if you rarely read the collection, it is recommended that you do not use the index.

3.37.2. Memory (RAM) usage

Since the index is stored in RAM, you should make sure 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 cause performance degradation.

3.37.3. Query restriction

The index cannot be used by the following query:

  • 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 checked with explain.

3.37.4. Index key limit

从2.6版本开始,如果现有的索引字段的值超过索引键的限制,MongoDB中不会创建索引。

3.37.5. Insert document exceeds index key limit

If the value of the index field of a document exceeds the limit of the index key, MongoDB does not convert any document into a collection of indexes. Similar to mongorestore and mongoimport tools.

3.37.6. Maximum range

  • Cannot have more than 64 indexes in the collection

  • The length of the index name cannot exceed 128 characters

  • A composite index can have up to 31 fields

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.