[erlang-questions] Mnesia Query Performance

Evans, Matthew <>
Thu Mar 10 16:25:55 CET 2011


I changed your read function to look like this instead:

read([]) ->
read([Key|Keys]) ->
    {atomic, _} =
        tx(fun() ->
                   mnesia:read(test_record, Key)

Before the change my test mirrored yours:


After the change it looks like:


I think that handling the whole "large" list within a single transaction is the cause of the slowdown. Not sure why.


-----Original Message-----
From:  [mailto:] On Behalf Of Rob Harrop
Sent: Thursday, March 10, 2011 10:03 AM
Subject: [erlang-questions] Mnesia Query Performance


I've been doing a bit of tuning on our use of mnesia in RabbitMQ and I'm 
a bit puzzled by the fact that read performance in transactions appears 
to be quadratic (or worse).

I ran a test in which I do only reads (no writes, no matching) on both 
set and ordered_set tables. From the results, it is clear that 
transaction execution time does not increase linearly:


Here the second slot in each tuple is the number of reads and the third 
slot is tx execution time in milliseconds.

I have attached the test code.

Am I doing something horribly wrong, or is this expected behaviour? If 
this is expected behaviour are there are known/accepted workarounds?

Kind Regards,

Rob Harrop

More information about the erlang-questions mailing list