MongoDB (2)-index creation

Source: Internet
Author: User

In the shell, look at the index that already exists in the collection, and you can run:

Db.things.getIndexes ()

To view all indexes in a database, you can run:

Db.system.indexes.find ()

Create an index
Db.things.ensureIndex ({j:1});


Build Options

The second parameter of the ENSUREINDEX function is the document/object that carries the creation option. These options are:

Options Value Default value
Background True/false False
Dropdups True/false False
Unique True/false False
Sparse True/false False
V The index version. 0= earlier than v2.0 version, 1 = smaller/faster (current) 1 in v2.0.1 is used by default except in special situations

http://blog.csdn.net/xinghebuluo/article/details/7221639

Http://www.cnblogs.com/stephen-liu74/archive/2012/08/01/2561557.html

MongoDB (2)-index creation

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.