MongoDB performance Optimization Five simple steps

Source: Internet
Author: User

Do you encounter performance problems when using MongoDB? Here is a summary of the five steps of MongoDB performance optimization, which I hope will help.

First step: Find the slow statement

In general, query statements are too slow and performance problem bottlenecks have a direct relationship, so you can use MongoDB's performance analysis tool to find these slow statements:

Db.setprofilinglevel (1, 100);

Step two: Using explain analysis

These slow statements are diagnosed by using explain. You can also mtools to analyze logs.

Step three: Create an index

After parsing, you need to create a new index to improve the performance of your query. Don't forget that you can create indexes in the background in Mondodb to avoid collections locks and system crashes.

Fourth step: Use sparse indexes to reduce space consumption

If you use sparse documents, and you use the keyword $exists, you can use sparse indexes to reduce the performance of your query by using a space footprint.

Fifth step: Read and write separation

If the read-write is in the master node, the slave node is always in the vacant state, which is a waste. For a report or to search for such a read operation can be fully implemented from the node, so to do is set in connection string into secondarypreferred.

Summary

Although these methods can play a role, the main purpose is to buy some time for the improvement of the architecture.


MongoDB performance Optimization Five simple steps

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.