How to optimize the performance of MongoDB (five simple Steps) _mongodb

Source: Internet
Author: User
Tags mongodb

MongoDB has been the most popular NoSQL, and according to Db-engines ranking the latest ranking, now MongoDB has defeated PostgreSQL leaped to the fourth place in the database ranking, after Oracle, MySQL and Microsoft SQ L Server, this article summarizes how to MongoDB performance tuning.

Have you ever encountered performance problems when using MongoDB? Here is a summary of the MongoDB performance optimization of the five steps, hope to be helpful.

First step: Find the slow statement

Generally speaking, query statements are too slow and performance problem bottlenecks have a direct relationship, so you can use MongoDB performance analysis tools to find these slow statements:

Db.setprofilinglevel (1, 100);

Step Two: Use explain analysis

These slow statements are diagnosed by using explain. In addition, you can mtools to analyze the log.

Step three: Create an index

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

Step Fourth: 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 space occupancy elevation queries.

Fifth step: Read and write separation

If read and write are in the main node, from the node has been in the vacant state, this is a waste. This can be done from the node for a report or search, so it is set to secondarypreferred in the connection string.

Small summary

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

Well, the above mentioned is the entire content of this article, I hope that we learn MongoDB performance optimization has helped.

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.