[erlang-questions] Some mnesia oddity

Ulf Wiger (TN/EAB) <>
Tue Oct 7 15:30:22 CEST 2008


Ben Hood skrev:
> 
> Is there some way to remove batches of records more efficiently?
> Would it make a difference to use a dirty_delete?

On replicated tables, using dirty writes or deletes for batch
updates can easily be _less_ efficient (and considerably less
safe) than using transactions.

The reason is that, if you take a table lock, the overhead
for starting the transaction, acquiring the lock and
committing (where all operations are included in the
commit message), becomes insignificant at some point,
compared to the combined overhead of making an rpc
call for each single operation.

If you _know_ that the table isn't replicated, there are
various dirty ways to speed things up, including perhaps
even changing the table copy type to ram, making all
changes directly on the ets table, and then changing the
copy type back to disc_copies (if that's what it was from
the beginning). Of course, if confronted, I'll deny that
I ever wrote this. ;-)

BR,
Ulf W



More information about the erlang-questions mailing list