[erlang-questions] dealing with large dicts

Richard Carlsson <>
Thu Sep 4 19:38:47 CEST 2008


Jacob Perkins wrote:
> T = fun(Term, Key) ->
>          [Dict1] = mnesia:read(Table, Term),
>          Dict2 = dict:store(Key, Val, Dict1),
>          ok = write_val(Table, Term, Dict2)
>      end.

I think the problem is not the updates to the dict itself, but the
fact that you are moving the entire dicts in and out of mnesia
(whose storage is based on ets/dets tables, which do not share memory
with your process). Each transaction thus consists of 1) a huge copy
out, 2) relatively minor rewrite of the dict structure, 3) copy entire
new structure back. You'll be better off just using a mnesia table (or
several) for your key/value data.

    /Richard



More information about the erlang-questions mailing list