MongoDB Index Limit

Source: Internet
Author: User
Tags arithmetic operators
Additional Overhead

Each index occupies a certain amount of storage space, and the indexes need to be manipulated when inserting, updating, and deleting operations. Therefore, if you seldom read the collection, we recommend that you do not use the index.

Memory (RAM) usage

Because the index is stored in memory (RAM), you should ensure that the size of the index does not exceed the memory limit.

If the size of the index is greater than the memory limit, MongoDB will delete some indexes, which will result in degraded performance.

Query limits

The index cannot be used by the following query:

  • Regular expressions and non-operators, such as $nin, $not, and so on.
  • Arithmetic operators, such as $mod, and so on.
  • $where clauses

Therefore, it is a good habit to detect whether your statements use indexes, which can be viewed with explain.

Index key limit

Starting with version 2.6, if the value of an existing indexed field exceeds the index key limit, the index is not created in MongoDB.

Insert document exceeds index key limit

If the index field value of the document exceeds the limit of the index key, MongoDB does not convert any documents into indexed collections. Similar to the Mongorestore and Mongoimport tools.

Maximum Range
  • Cannot have more than 64 indexes in a collection
  • Index name cannot exceed 125 characters in length
  • A composite index can have a maximum of 31 fields

MongoDB Index Limit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.