[erlang-questions] Passing records vs Mnesia lookups
Sun Apr 26 22:58:47 CEST 2009
2009/4/26 Amit Murthy <amit.murthy@REDACTED>:
> So the question is
> Is it better to read the record from mnesia once and send the complete
> record to each of the 40,000 processes
> Is it better to just send the key in the message and have each of the
> processes do an mnesia lookup
> The reason, I ask this is because the Efficiency Guide explicitly states
> "All data in messages between Erlang processes is copied, with the exception
> of refc binaries on the same Erlang node."
Reads from ets are also copying, so you end up copying in either case.
However, even mnesia:dirty_read() results in more ETS reads than just the
object. Mnesia has to find out where to read the object (it may not be local)
and what type of storage the table has, if the table exists locally.
ETS reads are protected by mutexes (on SMP). So is message passing, of
course, but the probability of lock contention is very much smaller with
More information about the erlang-questions