are Mnesia tables immutable?

Håkan Stenholm <>
Mon Jun 19 23:34:12 CEST 2006

Yariv Sadan wrote:

> Hi,
> I have a rather basic question: does Erlang's lack of mutable data
> structures mean that every time you modify a Mnesia (ets) table, the
> whole table is copied? This sounds very expensive... am I missing
> something?
Most data structures are non-mutable but mnesia, ets tables and process 
dictionaries _are_ mutable, data is copied in and out of mnesia/ets when 
accessing - it helps to think of them as erlang processes that one can 
send (write) and recieve (read) messages to/from.

Also note that a non-mutable datastructure doesn't necessarily need to 
copy everything, it's often sufficient, to build a new datastructure 
using mostly old unchanged parts. There are for example tree based data 
structures like gb_trees, that have O(log N)  read and write  costs -  
only a single tree branch is traveresed or updated, when accessing a 
specific tree element.

> Thanks
> Yariv

More information about the erlang-questions mailing list