Mnesia foldl without a transaction

Vladimir Sekissov svg@REDACTED
Wed Jul 7 20:27:06 CEST 2004


Good day,

If you don't care about transaction context it would be something
like this:

dirty_foldl(Fun, Acc, Tab) ->
  Key = mnesia:dirty_first(Tab),
  dirty_foldl(Fun, Acc, Tab, Key).

dirty_foldl(Fun, Ret, Tab, '$end_of_table') ->
  Ret;
dirty_foldl(Fun, Acc, Tab, Key) ->
  NxtAcc = Fun(Key, Acc),
  NxtKey = mnesia:dirty_next(Tab, Key),
  dirty_foldl(Fun, NxtAcc, Tab, NxtKey).

Best Regards,
Vladimir Sekissov

rvg> Hi All,
rvg> 
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> 
rvg> Regards,
rvg> 
rvg> Rudolph van Graan
rvg> 
rvg> 



More information about the erlang-questions mailing list