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.
Although these methods can play a certain role,But the main purpose is to get some time for structural improvement.
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- xcode - pod install [!] no `podfile 'found in the project directory
- dart - flutter: the instance member'stars' can't be accessed in an initializer error