MongoDB Performance Chapter

Source: Internet
Author: User
Tags create index

I. Index and its optimization

    1. Overview of Indexes
      1. The index of a database is like a directory in front of a book that speeds up data queries.
      2. Appropriate places to increase the index, unreasonable place to delete suboptimal index, can optimize poor performance of the application.
    2. Operation of the Index
      1. Base index: Db.ken.ensureIndex ({age:1})//CREATE index on column age

1 name _id_ is a system index and cannot be deleted.

    1. Silently CREATE INDEX: Db.ken.ensureIndex ({x:1},{background:true}); Background creation
    2. Document index: Embedded document not indexed
    3. Composite index: Multiple criteria together
    4. Unique index: Declaring uniqueness, that is, you cannot insert data with the same condition
    5. Force use Index: hint ({_id:1})
    6. Delete index: Db.ken.dropIndex ()
    7. Rebuild index: Db.ken.reIndex ()
    8. Use explain to see how a plan is executed

1 Millis field can see the time-consuming situation, indexbound can see whether the index is used, n represents the number of documents returned, nscaned represents the number of documents scanned.

2 If the information is incomplete, you can try to use a different version of the client.

    1. Optimizer: Profiler
      1. Open function.

1 can be started by adding parameters:-profiler=1

2 Execution Command: Db.setprofilinglevel (1)

    1. Query record: Db.system.profiler.find ()
    2. Performance Tuning Overview
      1. Performance Optimization principle: Modify one parameter at a time
      2. Parameters that affect performance: operating system, network, hardware, application server, application, database, query statement
    3. Common optimization Scheme
      1. Create a shrink index: When writing less Read more
      2. Limit number of returned bars: limit
      3. Query for fields that are used only
      4. Using capped Colletion
      5. Using Stored Procedures
      6. Force the use of indexes
      7. Using the profiler

Second, performance monitoring

    1. Mongosniff Tools
    2. Mongostat Tools
    3. Using Db.serverstatus ()
    4. Using Db.stats ()
    5. HTTP Monitoring interface

MongoDB Performance Chapter

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.