Differences between set and ordered_set in Mnesia?

What is the difference between a type set table and an ordered_set type table? I'm interested in differences in read / write performance, what the order is based on, effects in distributed nodes, etc.

+3
source share
2 answers

The order is based on the primary key, which means that the order_set tables are much faster when performing iteration matching / selection using complex primary keys. For example, if your record looks like {{Key, Val1}, Val2}, you can quickly or quickly choose Keyto receive Val1and Val2for each event Key. Other than that, I do not know a significant difference in read / write speed.

Fragmentation of ordered tables is also possible, although this means that the iteration will be partially ordered, but not fully ordered. Iterating over a single fragment is ordered, but the order from fragment to fragment is undefined.

+7
source

since the order comes from the source:

add_element(E, [H|Es]) when E > H -> [H|add_element(E, Es)];
add_element(E, [H|_]=Set) when E < H -> [E|Set];
add_element(_E, [_H|_]=Set) -> Set;     %E == H
add_element(E, []) ->[E].

Thus, the order looks like a direct <or> element comparison.

, , . , "" , . .

Erlang , .

:

, .

+1

Source: https://habr.com/ru/post/1710279/


All Articles