Mnesia foldl without a transaction
Wed Jul 7 20:27:06 CEST 2004
If you don't care about transaction context it would be something
dirty_foldl(Fun, Acc, Tab) ->
Key = mnesia:dirty_first(Tab),
dirty_foldl(Fun, Acc, Tab, Key).
dirty_foldl(Fun, Ret, Tab, '$end_of_table') ->
dirty_foldl(Fun, Acc, Tab, Key) ->
NxtAcc = Fun(Key, Acc),
NxtKey = mnesia:dirty_next(Tab, Key),
dirty_foldl(Fun, NxtAcc, Tab, NxtKey).
rvg> Hi All,
rvg> My question tonight is about iterating over an mnesia table with the
rvg> lowest possible overhead to the VM. As far as I can see, a
rvg> mnesia:foldl(...) call runs in a transaction and then blocks all other
rvg> mnesia calls. How would I get to iterate over an entire table with as
rvg> little as possible overhead? At the moment my table sits at about
rvg> 100000 records and it takes almost 10s to iterate. Any ideas on how to
rvg> speeds this up?
rvg> Rudolph van Graan
More information about the erlang-questions