Are transactions expensive?

Are Transactions expensive in Mongo DB?

Hi @Adhiraj_Kinlekar,

Multi-document transactions have more overhead than not using transactions, but if your use case requires this feature any overhead is a tradeoff versus the consequences of not having deterministic outcomes (all-or-nothing commits) of related data updates that need to be coordinated across multiple documents.

I would note that transaction overhead is not unique to MongoDB: transactions involve extra bookkeeping (for example, snapshot isolation) and long-running transactions can lead to memory pressure.

However, MongoDB’s flexible document model provides some alternatives to transactions that can be appropriate depending on your use case and data model. For example, related data can be embedded within a single document which can be updated atomically without using a transaction.

For some related reading, please see:

Regards,
Stennie