I have a mnesia ram_copies
table replicated to all available nodes. Almost all operations using this table perform in dirty mode. What are consequences of using mnesia:foldl
within ets
context?
mnesia:activity(ets, fun() ->
mnesia:foldl(fun(V, Acc) ->
case V#my_table.field > 0 of
true -> Acc;
false -> Acc + 1
end
end, 0, my_table)
end).
Given that you have
there's no difference in effect between ets
and async_dirty
. You may see some small speed improvement by bypassing a lot of tests that async_dirty
does, but I wouldn't expect it to be a noticeable gain.
As a general practice, I'd recommend using one transaction type everywhere (defined as a macro), and only diverge when you've found real speed improvements. Otherwise you risk an error such as adding a write to your ets
transaction or violating one of the other assumptions above, and then you're sunk.