Search code examples
database-designerlangschemamnesia

Differences between set and ordered_set in Mnesia?


What are the differences between a table of type set, and a table of type ordered_set? I'm interested in the differences in read/write performance, what the ordering is based on, the effects across distributed nodes, and such.


Solution

  • The ordering is based on the primary key, which means ordered_set tables are much faster at doing match/select iteration using complex primary keys. For example, if your record looks like {{Key, Val1}, Val2}, you can match or select on Key to very quickly get Val1 and Val2 for every occurance of Key. Other than that, I'm not aware of a significant difference in read/write speed.

    Fragmenting ordered_set tables is also possible, though it means 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.