MONGODB Basic Operations Data Creation Index

Source: Internet
Author: User
Tags mongodb

When the amount of data is low, the query is fast, but when the data is large, the query becomes very slow, in MongoDB

View Index
>  db.test_collection.getIndexes ()[    {        "V": 2,        "key" : {            "_id": 1         },        " Name ":" _id_ ",        " ns ":" Config.test_collection "    }]
Get indexed only _id




Create an index
> Db.test_collection.ensureIndex ({x:1}){    false,    " Numindexesbefore ": 1,    " Numindexesafter ": 2,    " OK ": 1}
If the number of documents, create an index, it takes a certain amount of time, if the system load is heavy, and there are many existing documents, you can not directly use this command to create, you need to use the database before the index is created, otherwise severely affect the database performance,





MONGODB Basic Operations Data Creation Index

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.