Database / Mnesia basics Interview questions
What are dirty operations in Mnesia?
Dirty operations (mnesia:dirty_read/1, mnesia:dirty_write/1,
mnesia:dirty_delete/1, and similar) perform a single read or write directly against the table,
bypassing transaction locking and the coordination needed to keep replicated copies perfectly in sync during
the operation.
mnesia:dirty_write(#person{id = 1, name = "Ada", age = 34}), mnesia:dirty_read({person, 1}).
They're significantly faster than their transactional counterparts precisely because they skip that coordination, which makes them a reasonable choice for high-throughput, low-consistency-requirement workloads (a hit counter, a cache-like table) where an occasional inconsistency during a concurrent update or a node failure mid-write is tolerable. They're the wrong choice whenever an operation depends on multiple related writes succeeding together, since dirty operations offer no atomicity across more than one call.
More Related questions...