Performance of listing a bag
Igor Ribeiro Sucupira
igorrs@REDACTED
Tue Apr 13 03:54:12 CEST 2010
Hi.
I've run the following test:
- Create a Mnesia test table of type bag, with disc_only_copies.
- Insert 170000 elements with the same key ({test, 1, 1} to {test, 1,
170000}). This took more than a minute, but I expected it.
- Fetch all of those elements at once, by key:
mnesia:transaction(fun mnesia:read/1, [{test, 1}]). %% Took less than
a second. Good.
- List all keys with mnesia:
mnesia:transaction(fun mnesia:all_keys/1, [test]). %% Takes forever,
consuming a lot of CPU.
It seems that, no matter the way I do it (using qlc or only mnesia), I
can always list all objects with key 1 very fast, but listing the full
table is extremely slow, although the data involved are precisely the
same in this example.
What's going on here? It's probably due to the implementation of
iteration on a dets table, but how does it happen?
Thanks.
Igor.
More information about the erlang-questions
mailing list