Rrrrr
Rrrrr

Reputation: 146

Mongodb asynchronous Inserts

I am using mongo3.0 with spring data I have question on the insert-async read that "mongodb inserts are asynchronous Mongo DB has asynchronous insert/update/remove operations. This means that when you issue an insert operation its a fire and forget operation where the database does not reply with the status of the insert operation."

Does this mean that the records are cached and mongo decides when to insert(physically write to disk) or the records are inserted instantly but there is no confirmation on the insert.

ref:-"https://mongodb.github.io/node-mongodb-native/api-articles/nodekoarticle1.html"

Upvotes: 5

Views: 9283

Answers (2)

Ely
Ely

Reputation: 11152

Does this mean that the records are cached and mongo decides when to insert(physically write to disk) or the records are inserted instantly but there is no confirmation on the insert.

No caching involved. The record insert command is sent and there is no return value to know the status. It's a fire and forget: Send command, that's it.

  • The advantage is that the application is faster, since it does not wait for a confirmation.
  • The disadvantage is that you don't get feedback whether the insert was successful or not.

However, as mentioned in another answer, you can use the write concern option. There are different level that you can set:

  • Unacknowledged (Your question was refering to this)
  • Acknowledged
  • Journaled
  • Replica Acknowledged

You can read about it in the MongoDB documentation.

Upvotes: 2

Raghuveer
Raghuveer

Reputation: 3057

MongoDB has confirmations options called concerns. Based on the usecase of the user you can use one of them. see link for complete information.

Upvotes: 0

Related Questions