[erlang-questions] is storing complex objects in ets a good idea?
Mon Apr 16 08:26:45 CEST 2007
2007/4/16, Ludovic Coquelle <>:
> In my application, I have to store a huge (but sparse) 2D matrix. I
> implemented that successfully using dict-of-dict kind of structure.
> I was then thinking to use a ets-of-dict structure: each line is a dict
> (containing all colum values) and I store each line (a dict) as an entry of
> a ets structure.
> But I read in the doc introduction of ets that "In the current
> implementation, every object insert and look-up operation results in one
> copy of the object.". Does this means that each access (even read) to an
> element of my matrix would imply a new dict copy?
Yes. While ets outperforms all other alternatives for random access for sets
of small objects (at least sets of size > 20), it doesn't necessarily do so
But if a dict-of-dict structure works, you might want to consider just using
ordset ets table. If you have a tuple as the key in an ordset table,
using a pattern where the first part of the key is bound, will be very
You can also create ets tables where the tuples stored have only one element
the key. Mnesia doesn't let you do that, but ets does.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions