MongoDB - findAndModify vs findOne Performance -


Search and modified queries are slow to find OneOne Assume that a collection documents are being inserted, then per second Which is 100-200 documents per second faster than finding a findOne or findAndModify that the collection is properly indexed and uses my query index

As you've already noted, . The purpose of the found and endoded () That is what is called it and "modify" the document which has been recovered, either by updating or by removing The atomic nature exists to avoid problems of existence, where your .findOne () document, then make changes to the content and then try .update () for example.

In the case of later use, there is "no guarantee" that the document is exactly what was there when it was "recovered" through "code" .findOne () . So in reality you could possibly overwrite the changes made by another process.

For display, it is comparing classic comparisons by comparing "apples for orange" because they are two different things. Returns the same result from a bus cursor .findOne () and in another, the .findAndModify () presumably holds the original document, changes with the default of worry typing or Other specific writing concerns, then either to retrieve or retrieve the document before discarding any control to modify others.

There are different levels of "locking" per MongoDB, but the thing is that a .findAndModify () is designed to do more work, Naturally it takes more time.

If you can only retrieve one document and then send an update then it is okay. Keep in mind that "apples from apples" should compare you to both of those tasks and how it works.

It may also be that you can check to establish writing concern, for these operations you may also be able to live with the fact that they write, are not accepted. But it is actually up to you, but in most people's opinion it is usually better to use those tools that are optimized for their purpose.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -