Home>

mongodb has always been the most popular nosql, and according to the latest ranking of db-engines ranking,Nowadays mongodb has beaten postgresql to the fourth place in the overall database rankings.Second only to oracle, mysql and microsoft sql server. This article gives you a brief summary of mongodb performance optimization.

mongodb has always been the most popular nosql, and according to the latest ranking of db-engines ranking,Now mongodb has beaten postgresql to the fourth place in the overall database rankings.Second only to oracle, mysql and microsoft sql server, this article summarizes how to tune mongodb for performance.

Step 1:Find the slow sentences

Generally speaking, the slowness of the query is directly related to the performance bottleneck.So you can use mongodb's performance analysis tools to find these slow statements:

db.setprofilinglevel (1, 100);

Step 2:Use explain analysis

Diagnose these slow statements by using explain.You can also use mtools to analyze logs.

Step 3: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 four:use sparse indexes to reduce space

If you use sparse documents and heavily use the keyword $exists, you can use sparse indexes to reduce space consumption and improve query performance.

Step five:read and write separation

If both reading and writing are on the master node,The slave node is always vacant,This is a waste.For reading operations such as reports or searches, it can be implemented in the slave nodes.So what to do is set to secondarypreferred in the connection string.

Small summary

Although these methods can play a certain role,But the main purpose is to get some time for structural improvement.

  • Previous Android implements the dialog box function at the bottom
  • Next Page content sorting plugin jSort usage method