Database / Mnesia basics Interview questions
What is mnesia:dirty_read/1?
mnesia:dirty_read({Table, Key}) fetches matching records directly, without opening a
transaction or taking any lock — it's the fastest way to read a single record when you don't need the
consistency guarantees a transaction provides.
mnesia:dirty_read({person, 1}). %% -> [#person{id = 1, name = "Ada", age = 34}]
Unlike mnesia:read/1, it can be called directly from anywhere in your code without wrapping it
in mnesia:transaction/1 first, and it returns the raw list of matching records rather than an
{atomic, ...}-wrapped tuple. The tradeoff is that it can read a value mid-update on a replicated
table if another node is writing at the same instant, since there's no lock coordinating the two.
More Related questions...